1 // RUN: %clang_cc1 -Wno-uninitialized -std=c++11 -verify %s
3 template<int> struct c { c(int) = delete; typedef void val; operator int() const; };
8 int k1 = a < b < c, d > ::val, e1;
9 int k2 = a < b, c < d > ::val, e2;
10 int k3 = b < a < c, d > ::val, e3;
11 int k4 = b < c, x, y = d > ::val, e4;
12 int k5 = T1 < b, &S::operator=(int); // expected-error {{extra qualification}}
13 int k6 = T2 < b, &S::operator= >::val;
14 int k7 = T1 < b, &S::operator>(int); // expected-error {{extra qualification}}
15 int k8 = T2 < b, &S::operator> >::val;
16 int k9 = T3 < a < b, c >> (d), e5 = 1 > (e4);
17 int k10 = 0 < T3 < a < b, c >> (d
18 ) // expected-error {{expected ';' at end of declaration}}
20 int k11 = 0 < 1, c<3>::*ptr;
21 int k12 = e < 0, int a<b<c>::* >(), e11;
24 int k1 = a < b < c, d > ::val,
25 int k2 = b < a < c, d > ::val,
26 int k3 = b < c, int x = 0 > ::val,
27 int k4 = a < b, T3 < int > >(), // expected-error {{must be an expression}}
28 int k5 = a < b, c < d > ::val,
29 int k6 = a < b, c < d > (n) // expected-error {{undeclared identifier 'n'}}
33 // T3<int> here is a parameter type, so must be declared before it is used.
34 int k1 = c < b, T3 < int > x = 0 // expected-error {{unexpected end of default argument expression}}
37 template<typename, int=0> struct T3 { T3(int); operator int(); };
40 int k1 = c < b, T3 < int > x = 0 // ok
43 // This is a one-parameter function. Ensure we don't typo-correct it to
44 // int = a < b, c < foobar > ()
45 // ... which would be a function with two parameters.
46 int f3(int = a < b, c < goobar > ());
47 static constexpr int (S::*f3_test)(int) = &S::f3;
51 int missing_default // expected-error {{missing default argument on parameter}}
56 int missing_default // expected-error {{missing default argument on parameter}}
61 unsigned int (missing_default) // expected-error {{missing default argument on parameter}}
64 template<int, int=0> struct a { static const int val = 0; operator int(); }; // expected-note {{here}}
65 static const int b = 0, c = 1, d = 2, goobar = 3;
66 template<int, typename> struct e { operator int(); };
70 mp3 = 0 > a<b<c>::val,
75 int np1 = e<0, int a<b<c,b<c>::*>();
77 static const int T1 = 4;
78 template<int, int &(S::*)(int)> struct T2 { static const int val = 0; };
81 namespace NoAnnotationTokens {
82 template<bool> struct Bool { Bool(int); };
83 static const bool in_class = false;
86 // Check we don't keep around a Bool<false> annotation token here.
87 int f(Bool<true> = X<Y, Bool<in_class> >(0));
89 // But it's OK if we do here.
90 int g(Bool<true> = Z<Y, Bool<in_class> = Bool<false>(0));
92 static const bool in_class = true;
93 template<int, typename U> using X = U;
94 static const int Y = 0, Z = 0;
98 namespace ImplicitInstantiation {
99 template<typename T> struct HasError { typename T::error error; }; // expected-error {{has no members}}
102 // This triggers the instantiation of the outer HasError<int> during
103 // disambiguation, even though it uses the inner HasError<int>.
104 void f(int a = X<Y, HasError<int>::Z >()); // expected-note {{in instantiation of}}
106 template<typename, typename> struct X { operator int(); };
108 template<typename> struct HasError { typedef int Z; };
115 template <int A, typename B> struct T { static int i; operator int(); };
117 int Foo (int i = T<1, int>::i);
121 int Foo (int i = T<1, int>::i);
122 template <int A, typename B> struct T {static int i;};
133 namespace Operators {
135 constexpr int operator,(const Y&, const Y&) { return 8; }
136 constexpr int operator>(const Y&, const Y&) { return 8; }
137 constexpr int operator<(const Y&, const Y&) { return 8; }
138 constexpr int operator>>(const Y&, const Y&) { return 8; }
141 typedef int (*Fn)(const Y&, const Y&);
143 Fn a = operator,, b = operator<, c = operator>;
144 void f(Fn a = operator,, Fn b = operator<, Fn c = operator>);
146 int k1 = T1<0, operator<, operator>, operator<>::val, l1;
147 int k2 = T1<0, operator>, operator,, operator,>::val, l2;
148 int k3 = T2<0, operator,(Y{}, Y{}), operator<(Y{}, Y{})>::val, l3;
149 int k4 = T2<0, operator>(Y{}, Y{}), operator,(Y{}, Y{})>::val, l4;
150 int k5 = T3<0, operator>>>::val, l5;
151 int k6 = T4<0, T3<0, operator>>>>::val, l6;
153 template<int, Fn, Fn, Fn> struct T1 { enum { val }; };
154 template<int, int, int> struct T2 { enum { val }; };
155 template<int, Fn> struct T3 { enum { val }; };
156 template<int, typename T> struct T4 : T {};
160 namespace ElaboratedTypeSpecifiers {
162 int f(int x = T<a, struct S>());
163 int h(int x = T<a, union __attribute__(()) U>());
164 int i(int x = T<a, enum E>());
165 int j(int x = T<a, struct S::template T<0, enum E>>());
166 template <int, typename> struct T { operator int(); };
167 static const int a = 0;
173 template <typename EncTraits> struct A {
174 void foo(int = EncTraits::template TypeEnc<int, int>::val); // ok