diff options
author | Hans Wennborg <hans@hanshq.net> | 2019-05-14 10:11:33 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2019-05-14 10:11:33 +0000 |
commit | b0dbc9612ff68d6db5fa6e4308a6538c394970ab (patch) | |
tree | 4c418b598778765ba6451443e6d9255f7e7dfe5b /clang/lib/AST/Decl.cpp | |
parent | a568222ddd4ce6354bdbc623ff725264da0cdd14 (diff) | |
download | bcm5719-llvm-b0dbc9612ff68d6db5fa6e4308a6538c394970ab.tar.gz bcm5719-llvm-b0dbc9612ff68d6db5fa6e4308a6538c394970ab.zip |
Revert r360637 "PR41817: Fix regression in r359260 that caused the MS compatibility"
> extension allowing a "static" declaration to follow an "extern"
> declaration to stop working.
It introduced asserts for some "static-following-extern" cases, breaking the
Chromium build. See the cfe-commits thread for reproducer.
llvm-svn: 360657
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 1ca66cfb5f1..4e42dd7d3bd 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -613,41 +613,12 @@ static LinkageInfo getExternalLinkageFor(const NamedDecl *D) { static StorageClass getStorageClass(const Decl *D) { if (auto *TD = dyn_cast<TemplateDecl>(D)) D = TD->getTemplatedDecl(); - if (!D) - return SC_None; - - if (auto *VD = dyn_cast<VarDecl>(D)) { - // Generally, the storage class is determined by the first declaration. - auto SC = VD->getCanonicalDecl()->getStorageClass(); - - // ... except that MSVC permits an 'extern' declaration to be redeclared - // 'static' as an extension. - if (SC == SC_Extern) { - for (auto *Redecl : VD->redecls()) { - if (Redecl->getStorageClass() == SC_Static) - return SC_Static; - if (Redecl->getStorageClass() != SC_Extern && - !Redecl->isLocalExternDecl() && !Redecl->getFriendObjectKind()) - break; - } - } - return SC; + if (D) { + if (auto *VD = dyn_cast<VarDecl>(D)) + return VD->getStorageClass(); + if (auto *FD = dyn_cast<FunctionDecl>(D)) + return FD->getStorageClass(); } - - if (auto *FD = dyn_cast<FunctionDecl>(D)) { - auto SC = FD->getCanonicalDecl()->getStorageClass(); - if (SC == SC_Extern) { - for (auto *Redecl : FD->redecls()) { - if (Redecl->getStorageClass() == SC_Static) - return SC_Static; - if (Redecl->getStorageClass() != SC_Extern && - !Redecl->isLocalExternDecl() && !Redecl->getFriendObjectKind()) - break; - } - } - return SC; - } - return SC_None; } @@ -663,7 +634,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D, // A name having namespace scope (3.3.6) has internal linkage if it // is the name of - if (getStorageClass(D) == SC_Static) { + if (getStorageClass(D->getCanonicalDecl()) == SC_Static) { // - a variable, variable template, function, or function template // that is explicitly declared static; or // (This bullet corresponds to C99 6.2.2p3.) |