From 56f453563440024d1beffe7fa20e81a358b31d0a Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 4 Oct 2016 18:10:23 +0000 Subject: [PATCH] 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 friend struct A; }; struct B { struct A *p; }; llvm-svn: 283235 --- clang/test/SemaCXX/elaborated-type-specifier.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clang/test/SemaCXX/elaborated-type-specifier.cpp b/clang/test/SemaCXX/elaborated-type-specifier.cpp index 81c5cb4..3701dd7 100644 --- a/clang/test/SemaCXX/elaborated-type-specifier.cpp +++ b/clang/test/SemaCXX/elaborated-type-specifier.cpp @@ -52,3 +52,12 @@ namespace test5 { } }; } + +namespace test6 { +struct C { + template 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}} +}; +} -- 2.7.4