diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-04 02:47:57 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-04 02:47:57 +0000 |
commit | 80a8689b274f758d9d7fb04c5cad81a582525497 (patch) | |
tree | 226185cbe41affcab10c4b77643efa11a9f2a9a2 | |
parent | d613ac9c57936d219d9eecba1d061a45ff7a3ae8 (diff) |
Fix linkage related crash.
This test was exactly the opposite of what it should be. We should check if
there old decl has linkage (where it makes sense) and if the new decl has
the extern keyword.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178735 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/linkage2.cpp | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 42d7d2bdf5..a25204d808 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2929,8 +2929,8 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous, Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); } - if (Old->hasExternalStorage() && - New->isLocalVarDecl() && !New->hasLinkage()) { + if (Old->hasLinkage() && New->isLocalVarDecl() && + !New->hasExternalStorage()) { Diag(New->getLocation(), diag::err_non_extern_extern) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); diff --git a/test/SemaCXX/linkage2.cpp b/test/SemaCXX/linkage2.cpp index c2dbf1e308..94ac25c99d 100644 --- a/test/SemaCXX/linkage2.cpp +++ b/test/SemaCXX/linkage2.cpp @@ -126,3 +126,11 @@ extern "C" { void __attribute__((overloadable)) test11_g(double); } } + +namespace test12 { + const int n = 0; + extern const int n; + void f() { + extern const int n; + } +} |