// RUN: %clang_cc1 -Wno-uninitialized -std=c++11 -verify %s template struct c { c(int) = delete; typedef void val; operator int() const; }; int val; int foobar; struct S { int k1 = a < b < c, d > ::val, e1; int k2 = a < b, c < d > ::val, e2; int k3 = b < a < c, d > ::val, e3; int k4 = b < c, x, y = d > ::val, e4; int k5 = T1 < b, &S::operator=(int); // expected-error {{extra qualification}} int k6 = T2 < b, &S::operator= >::val; int k7 = T1 < b, &S::operator>(int); // expected-error {{extra qualification}} int k8 = T2 < b, &S::operator> >::val; int k9 = T3 < a < b, c >> (d), e5 = 1 > (e4); int k10 = 0 < T3 < a < b, c >> (d ) // expected-error {{expected ';' at end of declaration}} , a > (e4); int k11 = 0 < 1, c<3>::*ptr; int k12 = e < 0, int a::* >(), e11; void f1( int k1 = a < b < c, d > ::val, int k2 = b < a < c, d > ::val, int k3 = b < c, int x = 0 > ::val, int k4 = a < b, T3 < int > >(), // expected-error {{must be an expression}} int k5 = a < b, c < d > ::val, int k6 = a < b, c < d > (n) // expected-error {{undeclared identifier 'n'}} ); void f2a( // T3 here is a parameter type, so must be declared before it is used. int k1 = c < b, T3 < int > x = 0 // expected-error {{unexpected end of default argument expression}} ); template struct T3 { T3(int); operator int(); }; void f2b( int k1 = c < b, T3 < int > x = 0 // ok ); // This is a one-parameter function. Ensure we don't typo-correct it to // int = a < b, c < foobar > () // ... which would be a function with two parameters. int f3(int = a < b, c < goobar > ()); static constexpr int (S::*f3_test)(int) = &S::f3; void f4( int k1 = a<1,2>::val, int missing_default // expected-error {{missing default argument on parameter}} ); void f5( int k1 = b < c, int missing_default // expected-error {{missing default argument on parameter}} ); void f6( int k = b < c, unsigned int (missing_default) // expected-error {{missing default argument on parameter}} ); template struct a { static const int val = 0; operator int(); }; // expected-note {{here}} static const int b = 0, c = 1, d = 2, goobar = 3; template struct e { operator int(); }; int mp1 = 0 < 1, a::*mp2, mp3 = 0 > a::val, a::*mp4 = 0, a::*mp5 {0}, a::*mp6; int np1 = e<0, int a::*>(); static const int T1 = 4; template struct T2 { static const int val = 0; }; }; namespace NoAnnotationTokens { template struct Bool { Bool(int); }; static const bool in_class = false; struct Test { // Check we don't keep around a Bool annotation token here. int f(Bool = X >(0)); // But it's OK if we do here. int g(Bool = Z = Bool(0)); static const bool in_class = true; template using X = U; static const int Y = 0, Z = 0; }; } namespace ImplicitInstantiation { template struct HasError { typename T::error error; }; // expected-error {{has no members}} struct S { // This triggers the instantiation of the outer HasError during // disambiguation, even though it uses the inner HasError. void f(int a = X::Z >()); // expected-note {{in instantiation of}} template struct X { operator int(); }; typedef int Y; template struct HasError { typedef int Z; }; }; HasError hei; } namespace CWG325 { template struct T { static int i; operator int(); }; class C { int Foo (int i = T<1, int>::i); }; class D { int Foo (int i = T<1, int>::i); template struct T {static int i;}; }; const int a = 0; typedef int b; T c; struct E { int n = T(c); }; } namespace Operators { struct Y {}; constexpr int operator,(const Y&, const Y&) { return 8; } constexpr int operator>(const Y&, const Y&) { return 8; } constexpr int operator<(const Y&, const Y&) { return 8; } constexpr int operator>>(const Y&, const Y&) { return 8; } struct X { typedef int (*Fn)(const Y&, const Y&); Fn a = operator,, b = operator<, c = operator>; void f(Fn a = operator,, Fn b = operator<, Fn c = operator>); int k1 = T1<0, operator<, operator>, operator<>::val, l1; int k2 = T1<0, operator>, operator,, operator,>::val, l2; int k3 = T2<0, operator,(Y{}, Y{}), operator<(Y{}, Y{})>::val, l3; int k4 = T2<0, operator>(Y{}, Y{}), operator,(Y{}, Y{})>::val, l4; int k5 = T3<0, operator>>>::val, l5; int k6 = T4<0, T3<0, operator>>>>::val, l6; template struct T1 { enum { val }; }; template struct T2 { enum { val }; }; template struct T3 { enum { val }; }; template struct T4 : T {}; }; } namespace ElaboratedTypeSpecifiers { struct S { int f(int x = T()); int g(int x = T()); int h(int x = T()); int i(int x = T()); int j(int x = T>()); template struct T { operator int(); }; static const int a = 0; enum E {}; }; }