r225781 - Revert "Sema: An extern declaration can't be a redeclaration of a parameter"
David Majnemer
david.majnemer at gmail.com
Tue Jan 13 02:14:57 PST 2015
Author: majnemer
Date: Tue Jan 13 04:14:57 2015
New Revision: 225781
URL: http://llvm.org/viewvc/llvm-project?rev=225781&view=rev
Log:
Revert "Sema: An extern declaration can't be a redeclaration of a parameter"
This reverts commit r225780, we can't compile line 181 in
sanitizer_platform_limits_posix.cc with this commit.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/private-extern.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=225781&r1=225780&r2=225781&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan 13 04:14:57 2015
@@ -3282,12 +3282,14 @@ void Sema::MergeVarDecl(VarDecl *New, Lo
}
// Check if extern is followed by non-extern and vice-versa.
- if (New->hasGlobalStorage() && !Old->hasLinkage() && Old->hasLocalStorage()) {
+ if (New->hasExternalStorage() &&
+ !Old->hasLinkage() && Old->isLocalVarDecl()) {
Diag(New->getLocation(), diag::err_extern_non_extern) << New->getDeclName();
Diag(OldLocation, PrevDiag);
return New->setInvalidDecl();
}
- if (Old->hasGlobalStorage() && !New->hasLinkage() && New->hasLocalStorage()) {
+ if (Old->hasLinkage() && New->isLocalVarDecl() &&
+ !New->hasExternalStorage()) {
Diag(New->getLocation(), diag::err_non_extern_extern) << New->getDeclName();
Diag(OldLocation, PrevDiag);
return New->setInvalidDecl();
Modified: cfe/trunk/test/Sema/private-extern.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/private-extern.c?rev=225781&r1=225780&r2=225781&view=diff
==============================================================================
--- cfe/trunk/test/Sema/private-extern.c (original)
+++ cfe/trunk/test/Sema/private-extern.c Tue Jan 13 04:14:57 2015
@@ -83,7 +83,3 @@ __private_extern__ int g19;
int g19 = 0;
__private_extern__ int g20 = 0;
-
-void f10(int g20) { // expected-note{{previous definition is here}}
- extern int g20; // expected-error{{extern declaration of 'g20' follows non-extern declaration}}
-}
More information about the cfe-commits
mailing list