1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
7 template<typename T
> struct Promote
;
9 template<> struct Promote
<short> {
13 template<> struct Promote
<int> {
17 template<> struct Promote
<float> {
21 Promote
<short>::type
*ret_intptr(int* ip
) { return ip
; }
22 Promote
<int>::type
*ret_intptr2(int* ip
) { return ip
; }
25 M::Promote
<int>::type
*ret_intptr3(int* ip
) { return ip
; }
26 M::template Promote
<int>::type
*ret_intptr4(int* ip
) { return ip
; }
27 #if __cplusplus <= 199711L
28 // expected-warning@-2 {{'template' keyword outside of a template}}
31 M::template Promote
<int> pi
;
32 #if __cplusplus <= 199711L
33 // expected-warning@-2 {{'template' keyword outside of a template}}
37 N::M::Promote
<int>::type
*ret_intptr5(int* ip
) { return ip
; }
38 ::N::M::Promote
<int>::type
*ret_intptr6(int* ip
) { return ip
; }
41 N::M::template; // expected-error{{expected unqualified-id}}
42 N::M::template Promote
; // expected-error{{expected unqualified-id}}
45 template<typename T
> struct A
;
52 struct B
; // expected-note{{declared as a non-template here}}
55 struct ::N::A
<int>::X
{
61 typedef typename
N::template B
<T
>::type type
; // expected-error{{'B' following the 'template' keyword does not refer to a template}} \
62 // expected-error{{expected member name}}
65 // Reduced from a Boost failure.
67 template <class T
> struct pair
{
71 static T pair
<T
>::* const mem_array
[2];
75 T pair
<T
>::* const pair
<T
>::mem_array
[2] = { &pair
<T
>::x
, &pair
<T
>::y
};
80 template<typename T
> T
f0();
83 template<typename T
> T
N1::f0() { }
86 template< typename
> struct has_xxx0
88 template< typename
> struct has_xxx0_introspect
90 template< typename
> struct has_xxx0_substitute
;
91 template< typename V
>
92 int int00( has_xxx0_substitute
< typename
V::template xxx
< > > = 0 );
94 static const int value
= has_xxx0_introspect
<int>::value
; // expected-error{{no member named 'value'}}
98 has_xxx0
<int>::type t
; // expected-note{{instantiation of}}
102 template<class ignored
> struct TypedefProvider
;
104 struct TemplateClass
: public TypedefProvider
<T
>
107 TemplateClass::Test::PrintSelf();
114 void nt() // expected-note{{function template 'nt' declared here}}
115 { nt
<>:: } // expected-error{{qualified name refers into a specialization of function template 'nt'}} \
116 // expected-error{{expected unqualified-id}}
119 void f(T
*); // expected-note{{function template 'f' declared here}}
122 void f(T
*, T
*); // expected-note{{function template 'f' declared here}}
125 f
<int>:: // expected-error{{qualified name refers into a specialization of function template 'f'}}
126 } // expected-error{{expected unqualified-id}}
129 template<typename T
> void f(); // expected-note{{function template 'f' declared here}}
132 template<typename T
, typename U
>
134 typedef typename
T::template f
<U
> type
; // expected-error{{template name refers to non-type template 'X::template f'}}
137 Y
<X
, int> yxi
; // expected-note{{in instantiation of template class 'PR9226::Y<PR9226::X, int>' requested here}}
141 template <typename T
>
142 struct s
; // expected-note{{template is declared here}}
144 template <typename T
>
146 int s
<T
>::template n
<T
>::* f
; // expected-error{{implicit instantiation of undefined template 'PR9449::s<int>'}} \
147 // expected-error{{no member named 'n'}}
150 template void f
<int>(); // expected-note{{in instantiation of}}