aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDecl.cpp3
-rw-r--r--test/SemaCXX/function-redecl.cpp16
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 252f94dc22..659d9638f4 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -5004,7 +5004,8 @@ void Sema::CheckShadow(Scope *S, VarDecl *D) {
template<typename T>
static bool mayConflictWithNonVisibleExternC(const T *ND) {
- return ND->isExternC() || ND->getDeclContext()->isTranslationUnit();
+ return ND->isExternC() ||
+ ND->getDeclContext()->getRedeclContext()->isTranslationUnit();
}
/// \brief Perform semantic checking on a newly-created variable
diff --git a/test/SemaCXX/function-redecl.cpp b/test/SemaCXX/function-redecl.cpp
index 7bf44b1c36..8cbda82c0b 100644
--- a/test/SemaCXX/function-redecl.cpp
+++ b/test/SemaCXX/function-redecl.cpp
@@ -145,3 +145,19 @@ namespace test4 {
float b; // expected-error {{redefinition of 'b' with a different type: 'float' vs 'int'}}
}
}
+
+extern "C" {
+ void test5_f() {
+ extern int test5_b; // expected-note {{previous definition is here}}
+ }
+}
+static float test5_b; // expected-error {{redefinition of 'test5_b' with a different type: 'float' vs 'int'}}
+
+extern "C" {
+ void test6_f() {
+ extern int test6_b; // expected-note {{previous definition is here}}
+ }
+}
+extern "C" {
+ static float test6_b; // expected-error {{redefinition of 'test6_b' with a different type: 'float' vs 'int'}}
+}