Author: rnk
Date: Tue Oct  4 13:10:23 2016
New Revision: 283235

URL: http://llvm.org/viewvc/llvm-project?rev=283235&view=rev
Log:
Test what happens when tag lookup and redeclaration lookup disagree

Clang has a diagnostic for the what happens when an elaborated type
implicitly creates a tag declaration and the initial tag lookup fails,
but the redeclaration lookup succeeds and finds a non-tag type. However,
it wasn't tested, and looked like dead code. After much staring, we
discovered how to exercise it, and are now committing the test for
posterity.

In this example, the tag lookup will not find A, but then when we go to
insert a declaration of A at global scope, we discover the template
friend, which is not a tag type.

  struct C {
    template <typename> friend struct A;
  };
  struct B {
    struct A *p;
  };

Modified:
    cfe/trunk/test/SemaCXX/elaborated-type-specifier.cpp

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=283235&r1=283234&r2=283235&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/elaborated-type-specifier.cpp (original)
+++ cfe/trunk/test/SemaCXX/elaborated-type-specifier.cpp Tue Oct  4 13:10:23 
2016
@@ -52,3 +52,12 @@ namespace test5 {
     }
   };
 }
+
+namespace test6 {
+struct C {
+  template <typename> friend struct A; // expected-note {{'A' declared here}}
+};
+struct B {
+  struct A *p; // expected-error {{implicit declaration introduced by 
elaborated type conflicts with a template of the same name}}
+};
+}


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to