From 6483d22f1b0be9d7ce08689c83f6fa3cb7ac33e0 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 21 Apr 2012 01:27:54 +0000 Subject: When declaring a template, check that the context doesn't already contain a declaration of the same name. r155187 caused us to miss this if the prior declaration did not declare a type. llvm-svn: 155269 --- clang/test/SemaTemplate/class-template-decl.cpp | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'clang/test/SemaTemplate/class-template-decl.cpp') diff --git a/clang/test/SemaTemplate/class-template-decl.cpp b/clang/test/SemaTemplate/class-template-decl.cpp index bd2accee3c2..23385a701e3 100644 --- a/clang/test/SemaTemplate/class-template-decl.cpp +++ b/clang/test/SemaTemplate/class-template-decl.cpp @@ -94,3 +94,46 @@ namespace rdar9676205 { }; }; } + +namespace redecl { + int A; // expected-note {{here}} + template struct A; // expected-error {{different kind of symbol}} + + int B; + template struct B { // expected-error {{different kind of symbol}} + }; + + template struct F; + template struct K; + + int G, H; + + struct S { + int C; // expected-note {{here}} + template struct C; // expected-error {{different kind of symbol}} + + int D; + template struct D { // expected-error {{different kind of symbol}} + }; + + int E; + template friend struct E { // expected-error {{cannot define a type in a friend}} + }; + + int F; + template friend struct F; // ok, redecl::F + + template struct G; // ok + + template friend struct H; // expected-error {{different kind of symbol}} + + int I, J, K; + + struct U { + template struct I; // ok + template struct J { // ok + }; + template friend struct K; // ok, redecl::K + }; + }; +} -- cgit v1.2.3