Merge visibility from previous decls before looking at visibility pragma. This
is a bit fuzzy, but matches gcc behavior and existing code bases seem to
depend on it.
llvm-svn: 160364
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 342acf8..4041ccf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8880,10 +8880,6 @@
if (Attr)
ProcessDeclAttributeList(S, New, Attr);
- // If there's a #pragma GCC visibility in scope, set the visibility of this
- // record.
- AddPushedVisibilityAttribute(New);
-
// If we're declaring or defining a tag in function prototype scope
// in C, note that this type can only be used within the function.
if (Name && S->isFunctionPrototypeScope() && !getLangOpts().CPlusPlus)
@@ -8946,6 +8942,10 @@
if (PrevDecl)
mergeDeclAttributes(New, PrevDecl);
+ // If there's a #pragma GCC visibility in scope, set the visibility of this
+ // record.
+ AddPushedVisibilityAttribute(New);
+
OwnedDecl = true;
return New;
}