From bda7fdb49cd3d22363a83b8dc78e5a0bafea00b9 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 28 Nov 2018 05:15:46 +0000 Subject: [PATCH] PR12884: Add test (bug is already fixed). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347729 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/SemaTemplate/typename-specifier-3.cpp | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/test/SemaTemplate/typename-specifier-3.cpp b/test/SemaTemplate/typename-specifier-3.cpp index dfab5a0130..dc9d00601d 100644 --- a/test/SemaTemplate/typename-specifier-3.cpp +++ b/test/SemaTemplate/typename-specifier-3.cpp @@ -18,3 +18,59 @@ B c() { template struct test2 { T b() { return typename T::a; } }; // expected-error{{expected '(' for function-style cast or type construction}} template struct test3 { T b() { return typename a; } }; // expected-error{{expected a qualified name after 'typename'}} template struct test4 { T b() { return typename ::a; } }; // expected-error{{refers to non-type member}} expected-error{{expected '(' for function-style cast or type construction}} + +// PR12884 +namespace PR12884_original { + template struct A { + struct B { + template struct X {}; + typedef int arg; + }; + struct C { + typedef B::X x; // expected-error {{missing 'typename'}} + }; + }; + + template <> struct A::B { + template struct X {}; + static const int arg = 0; + }; + + A::C::x a; +} +namespace PR12884_half_fixed { + template struct A { + struct B { + template struct X {}; + typedef int arg; + }; + struct C { + typedef typename B::X x; // expected-error {{use 'template'}} expected-error {{refers to non-type}} + }; + }; + + template <> struct A::B { + template struct X {}; + static const int arg = 0; // expected-note {{here}} + }; + + A::C::x a; // expected-note {{here}} +} +namespace PR12884_fixed { + template struct A { + struct B { + template struct X {}; + typedef int arg; + }; + struct C { + typedef typename B::template X x; + }; + }; + + template <> struct A::B { + template struct X {}; + static const int arg = 0; + }; + + A::C::x a; // ok +} -- 2.50.1