]> granicus.if.org Git - clang/commitdiff
When we generate a redeclaration for an
authorJohn McCall <rjmccall@apple.com>
Wed, 14 May 2014 18:31:48 +0000 (18:31 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 14 May 2014 18:31:48 +0000 (18:31 +0000)
elaborated-type-specifier, place it in the correct
context.

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

lib/Sema/SemaDecl.cpp
test/SemaCXX/elaborated-type-specifier.cpp
test/SemaCXX/friend.cpp

index c43c881f1ef3738c6c1dfe4f6d81cea52bc84e1f..2f434cedfe6c5df2387fe22a13de81abee948d20 100644 (file)
@@ -10981,7 +10981,15 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
             }
 
             // Okay, this is definition of a previously declared or referenced
-            // tag PrevDecl. We're going to create a new Decl for it.
+            // tag. We're going to create a new Decl for it.
+          }
+
+          // Okay, we're going to make a redeclaration.  If this is some kind
+          // of reference, make sure we build the redeclaration in the same DC
+          // as the original, and ignore the current access specifier.
+          if (TUK == TUK_Friend || TUK == TUK_Reference) {
+            SearchDC = PrevTagDecl->getDeclContext();
+            AS = AS_none;
           }
         }
         // If we get here we have (another) forward declaration or we
index 1b1770a89f8506971486b2e2bcc140bc39f8a1b3..81c5cb4eac59bd4da3c1b7acb66c5d1d5e9e2bd9 100644 (file)
@@ -43,3 +43,12 @@ int test_funcparam_scope(struct S5 * s5) {
   if (s5 == s5_2) return 1; // expected-error {{comparison of distinct pointer types ('struct S5 *' and 'struct S5 *')}}
   return 0;
 }
+
+namespace test5 {
+  struct A {
+    class __attribute__((visibility("hidden"))) B {};
+
+    void test(class __attribute__((visibility("hidden"), noreturn)) B b) { // expected-warning {{'noreturn' attribute only applies to functions and methods}}
+    }
+  };
+}
index aed2ab2c7d0c0e34eb70db544b332ad07ba7af04..03589101e1b85edf3c2623ba09e4b4df09a32caf 100644 (file)
@@ -288,3 +288,11 @@ namespace test10 {
     ::test10::f10_d(z);
   }
 }
+
+namespace test11 {
+  class __attribute__((visibility("hidden"))) B;
+
+  class A {
+    friend class __attribute__((visibility("hidden"), noreturn)) B; // expected-warning {{'noreturn' attribute only applies to functions and methods}}
+  };
+}