r175903 - Make sure pragmas don't attach visibility attributes to auto variables with
Rafael Espindola
rafael.espindola at gmail.com
Fri Feb 22 09:59:17 PST 2013
Author: rafael
Date: Fri Feb 22 11:59:16 2013
New Revision: 175903
URL: http://llvm.org/viewvc/llvm-project?rev=175903&view=rev
Log:
Make sure pragmas don't attach visibility attributes to auto variables with
internal linkage.
Added:
cfe/trunk/test/SemaCXX/auto-pragma.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=175903&r1=175902&r2=175903&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Feb 22 11:59:16 2013
@@ -4908,11 +4908,6 @@ Sema::ActOnVariableDeclarator(Scope *S,
!NewVD->isInvalidDecl())
RegisterLocallyScopedExternCDecl(NewVD, Previous, S);
- // If there's a #pragma GCC visibility in scope, and this isn't a class
- // member, set the visibility of this variable.
- if (NewVD->getLinkage() == ExternalLinkage && !DC->isRecord())
- AddPushedVisibilityAttribute(NewVD);
-
return NewVD;
}
@@ -7880,10 +7875,16 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
// Note that we are no longer parsing the initializer for this declaration.
ParsingInitForAutoVars.erase(ThisDecl);
- const VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
+ VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
if (!VD)
return;
+ const DeclContext *DC = VD->getDeclContext();
+ // If there's a #pragma GCC visibility in scope, and this isn't a class
+ // member, set the visibility of this variable.
+ if (VD->getLinkage() == ExternalLinkage && !DC->isRecord())
+ AddPushedVisibilityAttribute(VD);
+
if (VD->isFileVarDecl())
MarkUnusedFileScopedDecl(VD);
Added: cfe/trunk/test/SemaCXX/auto-pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/auto-pragma.cpp?rev=175903&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/auto-pragma.cpp (added)
+++ cfe/trunk/test/SemaCXX/auto-pragma.cpp Fri Feb 22 11:59:16 2013
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump -ast-dump-filter AutoVar | FileCheck %s
+
+namespace {
+ class foo {
+ };
+}
+
+#pragma GCC visibility push(hidden)
+auto AutoVar = foo();
+
+// CHECK: VarDecl {{.*}} AutoVar
+// CHECK-NOT: VisibilityAttr
More information about the cfe-commits
mailing list