]> granicus.if.org Git - clang/commitdiff
Merge existing attributes before processing pragmas in friend template
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 22 Aug 2012 14:52:14 +0000 (14:52 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 22 Aug 2012 14:52:14 +0000 (14:52 +0000)
declarations.
Fixes pr13662.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162360 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaCXX/pragma-visibility.cpp

index 4dbf3e45b38748c9a2f8a94adbf38c816af7df4b..98497cb64d12e84ecd0ab90a756e9982cf9a71f0 100644 (file)
@@ -1104,6 +1104,9 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
   if (Attr)
     ProcessDeclAttributeList(S, NewClass, Attr);
 
+  if (PrevClassTemplate)
+    mergeDeclAttributes(NewClass, PrevClassTemplate->getTemplatedDecl());
+
   AddPushedVisibilityAttribute(NewClass);
 
   if (TUK != TUK_Friend)
@@ -1138,8 +1141,6 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
     NewTemplate->setInvalidDecl();
     NewClass->setInvalidDecl();
   }
-  if (PrevClassTemplate)
-    mergeDeclAttributes(NewClass, PrevClassTemplate->getTemplatedDecl());
 
   ActOnDocumentableDecl(NewTemplate);
 
index e3ef97a744472f356022a11b61ade9ae25ec411f..18c59c8c10ff4f6bb76db897ac6de85cbba12403 100644 (file)
@@ -21,3 +21,10 @@ void f() {
   #pragma GCC visibility push(protected)
   #pragma GCC visibility pop
 }
+
+namespace pr13662 {
+#pragma GCC visibility push(hidden)
+  template<class T> class __attribute__((__visibility__("default"))) foo;
+  class bar { template<class T> friend class foo; };
+#pragma GCC visibility pop
+}