r208799 - When we generate a redeclaration for an

John McCall rjmccall at apple.com
Wed May 14 11:31:49 PDT 2014


Author: rjmccall
Date: Wed May 14 13:31:48 2014
New Revision: 208799

URL: http://llvm.org/viewvc/llvm-project?rev=208799&view=rev
Log:
When we generate a redeclaration for an
elaborated-type-specifier, place it in the correct
context.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/elaborated-type-specifier.cpp
    cfe/trunk/test/SemaCXX/friend.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=208799&r1=208798&r2=208799&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 14 13:31:48 2014
@@ -10981,7 +10981,15 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
             }
 
             // 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

Modified: cfe/trunk/test/SemaCXX/elaborated-type-specifier.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/elaborated-type-specifier.cpp?rev=208799&r1=208798&r2=208799&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/elaborated-type-specifier.cpp (original)
+++ cfe/trunk/test/SemaCXX/elaborated-type-specifier.cpp Wed May 14 13:31:48 2014
@@ -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}}
+    }
+  };
+}

Modified: cfe/trunk/test/SemaCXX/friend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend.cpp?rev=208799&r1=208798&r2=208799&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/friend.cpp (original)
+++ cfe/trunk/test/SemaCXX/friend.cpp Wed May 14 13:31:48 2014
@@ -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}}
+  };
+}





More information about the cfe-commits mailing list