summaryrefslogtreecommitdiffstats
path: root/lib/Sema
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-01-13 09:55:56 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-01-13 09:55:56 +0000
commit940569b4717ba5e6f9faca6682ae30e68e253660 (patch)
treedc122cd9d15fd080cc60dce9122e89567259e18a /lib/Sema
parent424535e64f91f87235451d059f68e8cd5687453d (diff)
Sema: An extern declaration can't be a redeclaration of a parameter
In the following: void f(int x) { extern int x; } The second declaration of 'x' shouldn't be considered a redeclaration of the parameter. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225780 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaDecl.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index baa6822da7..82ffd4da5f 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3282,14 +3282,12 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) {
}
// Check if extern is followed by non-extern and vice-versa.
- if (New->hasExternalStorage() &&
- !Old->hasLinkage() && Old->isLocalVarDecl()) {
+ if (New->hasGlobalStorage() && !Old->hasLinkage() && Old->hasLocalStorage()) {
Diag(New->getLocation(), diag::err_extern_non_extern) << New->getDeclName();
Diag(OldLocation, PrevDiag);
return New->setInvalidDecl();
}
- if (Old->hasLinkage() && New->isLocalVarDecl() &&
- !New->hasExternalStorage()) {
+ if (Old->hasGlobalStorage() && !New->hasLinkage() && New->hasLocalStorage()) {
Diag(New->getLocation(), diag::err_non_extern_extern) << New->getDeclName();
Diag(OldLocation, PrevDiag);
return New->setInvalidDecl();