r178735 - Fix linkage related crash.
Rafael Espindola
rafael.espindola at gmail.com
Wed Apr 3 19:47:57 PDT 2013
Author: rafael
Date: Wed Apr 3 21:47:57 2013
New Revision: 178735
URL: http://llvm.org/viewvc/llvm-project?rev=178735&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/linkage2.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=178735&r1=178734&r2=178735&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Apr 3 21:47:57 2013
@@ -2929,8 +2929,8 @@ void Sema::MergeVarDecl(VarDecl *New, Lo
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();
Modified: cfe/trunk/test/SemaCXX/linkage2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/linkage2.cpp?rev=178735&r1=178734&r2=178735&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/linkage2.cpp (original)
+++ cfe/trunk/test/SemaCXX/linkage2.cpp Wed Apr 3 21:47:57 2013
@@ -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;
+ }
+}
More information about the cfe-commits
mailing list