diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-01-13 09:55:56 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-01-13 09:55:56 +0000 |
commit | 940569b4717ba5e6f9faca6682ae30e68e253660 (patch) | |
tree | dc122cd9d15fd080cc60dce9122e89567259e18a /lib/Sema | |
parent | 424535e64f91f87235451d059f68e8cd5687453d (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.cpp | 6 |
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(); |