r360657 - Revert r360637 "PR41817: Fix regression in r359260 that caused the MS compatibility"
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Tue May 14 03:11:34 PDT 2019
Author: hans
Date: Tue May 14 03:11:33 2019
New Revision: 360657
URL: http://llvm.org/viewvc/llvm-project?rev=360657&view=rev
Log:
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.
Removed:
cfe/trunk/test/CodeGen/ms-compat-extern-static.c
Modified:
cfe/trunk/lib/AST/Decl.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=360657&r1=360656&r2=360657&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue May 14 03:11:33 2019
@@ -613,41 +613,12 @@ static LinkageInfo getExternalLinkageFor
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::getLVForNamespaceScopeD
// 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.)
Removed: cfe/trunk/test/CodeGen/ms-compat-extern-static.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-compat-extern-static.c?rev=360656&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/ms-compat-extern-static.c (original)
+++ cfe/trunk/test/CodeGen/ms-compat-extern-static.c (removed)
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -fms-extensions -triple x86_64-windows | FileCheck %s
-
-// CHECK: @n = internal global i32 1
-extern int n;
-static int n = 1;
-int *use = &n;
-
-// CHECK: define internal void @f(
-extern void f();
-static void f() {}
-void g() { return f(); }
More information about the cfe-commits
mailing list