diff options
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 5 | ||||
-rw-r--r-- | test/SemaCXX/function-redecl.cpp | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 35af7b7264..252f94dc22 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5004,10 +5004,7 @@ void Sema::CheckShadow(Scope *S, VarDecl *D) { template<typename T> static bool mayConflictWithNonVisibleExternC(const T *ND) { - VarDecl::StorageClass SC = ND->getStorageClass(); - if (ND->isExternC() && (SC == SC_Extern || SC == SC_PrivateExtern)) - return true; - return ND->getDeclContext()->isTranslationUnit(); + return ND->isExternC() || ND->getDeclContext()->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 4a5638f84e..7bf44b1c36 100644 --- a/test/SemaCXX/function-redecl.cpp +++ b/test/SemaCXX/function-redecl.cpp @@ -134,3 +134,14 @@ namespace test3 { } } float test3_x; // expected-error {{redefinition of 'test3_x' with a different type: 'float' vs 'int'}} + +namespace test4 { + extern "C" { + void f() { + extern int b; // expected-note {{previous definition is here}} + } + } + extern "C" { + float b; // expected-error {{redefinition of 'b' with a different type: 'float' vs 'int'}} + } +} |