forked from OSchip/llvm-project
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:
parent
fce1dad042
commit
869fe0448b
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue