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.

llvm-svn: 178735
This commit is contained in:
Rafael Espindola 2013-04-04 02:47:57 +00:00
parent fce1dad042
commit 869fe0448b
2 changed files with 10 additions and 2 deletions

View File

@ -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();

View File

@ -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;
}
}