// RUN: %clang_cc1 -fsyntax-only -verify %s template struct is_same { static const bool value = false; }; template struct is_same { static const bool value = true; }; template struct metafun_apply2 { typedef typename MetaFun::template apply inner; typedef typename inner::type type; }; template struct pair; struct make_pair { template struct apply { typedef pair type; }; }; int a0[is_same::type, pair >::value? 1 : -1]; int a1[is_same< typename make_pair::template apply, // expected-warning{{'template' keyword outside of a template}} \ // expected-warning{{'typename' occurs outside of a template}} make_pair::apply >::value? 1 : -1]; template struct swap_and_apply2 { template struct apply { typedef typename MetaFun::template apply new_metafun; typedef typename new_metafun::type type; }; }; int a2[is_same::apply::type, pair >::value? 1 : -1]; template struct swap_and_apply2b { template struct apply { typedef typename MetaFun::template apply::type type; }; }; int a3[is_same::apply::type, pair >::value? 1 : -1]; template struct X0 { template struct Inner; void f0(X0::Inner); // expected-note{{here}} void f0(typename X0::Inner); // expected-error{{redecl}} void f1(X0::Inner); // expected-note{{here}} void f1(typename X0::template Inner); // expected-error{{redecl}} void f2(typename X0::Inner::type); // expected-note{{here}} void f2(typename X0::template Inner::type); // expected-error{{redecl}} }; namespace PR6236 { template struct S { }; template struct S { template struct K { }; void f() { typedef typename S::template K Foo; } }; } namespace PR6268 { template struct Outer { template struct Inner {}; template typename Outer::template Inner foo(typename Outer::template Inner); }; template template typename Outer::template Inner Outer::foo(typename Outer::template Inner) { return Inner(); } } namespace PR6463 { struct B { typedef int type; }; // expected-note 2{{member found by ambiguous name lookup}} struct C { typedef int type; }; // expected-note 2{{member found by ambiguous name lookup}} template struct A : B, C { type& a(); // expected-error{{found in multiple base classes}} int x; }; // FIXME: Improve source location info here. template typename A::type& A::a() { // expected-error{{found in multiple base classes}} return x; } } namespace PR7419 { template struct S { typedef typename T::Y T2; typedef typename T2::Z T3; typedef typename T3::W T4; T4 *f(); typedef typename T::template Y TT2; typedef typename TT2::template Z TT3; typedef typename TT3::template W TT4; TT4 g(); }; template typename T::Y::Z::W *S::f() { } template typename T::template Y::template Z::template W S::g() { } } namespace rdar8740998 { template struct X : public T { using T::iterator; // expected-note{{add 'typename' to treat this using declaration as a type}} \ // expected-error{{dependent using declaration resolved to type without 'typename'}} void f() { typename X::iterator i; // expected-error{{typename specifier refers to a dependent using declaration for a value 'iterator' in 'X'}} } }; struct HasIterator { typedef int *iterator; // expected-note{{target of using declaration}} }; void test_X(X xi) { // expected-note{{in instantiation of template class}} xi.f(); } } namespace rdar9068589 { // From GCC PR c++/13950 template struct Base {}; template struct Derived: public Base { typename Derived::template Base* p1; }; }