1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 5*0a6a1f1dSLionel Sambuc 6*0a6a1f1dSLionel Sambuc namespace dr300 { // dr300: yes f(R (&)(A))7*0a6a1f1dSLionel Sambuc template<typename R, typename A> void f(R (&)(A)) {} 8*0a6a1f1dSLionel Sambuc int g(int); h()9*0a6a1f1dSLionel Sambuc void h() { f(g); } 10*0a6a1f1dSLionel Sambuc } 11*0a6a1f1dSLionel Sambuc 12*0a6a1f1dSLionel Sambuc namespace dr301 { // dr301: yes 13*0a6a1f1dSLionel Sambuc // see also dr38 14*0a6a1f1dSLionel Sambuc struct S; 15*0a6a1f1dSLionel Sambuc template<typename T> void operator+(T, T); 16*0a6a1f1dSLionel Sambuc void operator-(S, S); 17*0a6a1f1dSLionel Sambuc f()18*0a6a1f1dSLionel Sambuc void f() { 19*0a6a1f1dSLionel Sambuc bool a = (void(*)(S, S))operator+<S> < 20*0a6a1f1dSLionel Sambuc (void(*)(S, S))operator+<S>; 21*0a6a1f1dSLionel Sambuc bool b = (void(*)(S, S))operator- < 22*0a6a1f1dSLionel Sambuc (void(*)(S, S))operator-; 23*0a6a1f1dSLionel Sambuc bool c = (void(*)(S, S))operator+ < 24*0a6a1f1dSLionel Sambuc (void(*)(S, S))operator-; // expected-error {{expected '>'}} 25*0a6a1f1dSLionel Sambuc } 26*0a6a1f1dSLionel Sambuc f()27*0a6a1f1dSLionel Sambuc template<typename T> void f() { 28*0a6a1f1dSLionel Sambuc typename T::template operator+<int> a; // expected-error {{typename specifier refers to a non-type template}} expected-error +{{}} 29*0a6a1f1dSLionel Sambuc // FIXME: This shouldn't say (null). 30*0a6a1f1dSLionel Sambuc class T::template operator+<int> b; // expected-error {{identifier followed by '<' indicates a class template specialization but (null) refers to a function template}} 31*0a6a1f1dSLionel Sambuc enum T::template operator+<int> c; // expected-error {{expected identifier}} expected-error {{does not declare anything}} 32*0a6a1f1dSLionel Sambuc enum T::template operator+<int>::E d; // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}} expected-error {{forward reference}} 33*0a6a1f1dSLionel Sambuc enum T::template X<int>::E e; 34*0a6a1f1dSLionel Sambuc T::template operator+<int>::foobar(); // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}} 35*0a6a1f1dSLionel Sambuc T::template operator+<int>(0); // ok 36*0a6a1f1dSLionel Sambuc } 37*0a6a1f1dSLionel Sambuc 38*0a6a1f1dSLionel Sambuc template<typename T> class operator&<T*> {}; // expected-error +{{}} 39*0a6a1f1dSLionel Sambuc template<typename T> class T::operator& {}; // expected-error +{{}} 40*0a6a1f1dSLionel Sambuc template<typename T> class S::operator&<T*> {}; // expected-error +{{}} 41*0a6a1f1dSLionel Sambuc } 42*0a6a1f1dSLionel Sambuc 43*0a6a1f1dSLionel Sambuc namespace dr302 { // dr302: yes 44*0a6a1f1dSLionel Sambuc struct A { A(); ~A(); }; 45*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 46*0a6a1f1dSLionel Sambuc struct B { // expected-error {{implicit default constructor for 'dr302::B' must explicitly initialize the const member 'n'}} 47*0a6a1f1dSLionel Sambuc const int n; // expected-note {{declared here}} 48*0a6a1f1dSLionel Sambuc A a; 49*0a6a1f1dSLionel Sambuc } b = B(); // expected-note {{first required here}} 50*0a6a1f1dSLionel Sambuc // Trivial default constructor C::C() is not called here. 51*0a6a1f1dSLionel Sambuc struct C { 52*0a6a1f1dSLionel Sambuc const int n; 53*0a6a1f1dSLionel Sambuc } c = C(); 54*0a6a1f1dSLionel Sambuc #else 55*0a6a1f1dSLionel Sambuc struct B { 56*0a6a1f1dSLionel Sambuc const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}} 57*0a6a1f1dSLionel Sambuc A a; 58*0a6a1f1dSLionel Sambuc } b = B(); // expected-error {{call to implicitly-deleted default constructor}} 59*0a6a1f1dSLionel Sambuc // C::C() is called here, because even though it's trivial, it's deleted. 60*0a6a1f1dSLionel Sambuc struct C { 61*0a6a1f1dSLionel Sambuc const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}} 62*0a6a1f1dSLionel Sambuc } c = C(); // expected-error {{call to implicitly-deleted default constructor}} 63*0a6a1f1dSLionel Sambuc struct D { 64*0a6a1f1dSLionel Sambuc const int n = 0; 65*0a6a1f1dSLionel Sambuc } d = D(); 66*0a6a1f1dSLionel Sambuc #endif 67*0a6a1f1dSLionel Sambuc } 68*0a6a1f1dSLionel Sambuc 69*0a6a1f1dSLionel Sambuc // dr303: na 70*0a6a1f1dSLionel Sambuc 71*0a6a1f1dSLionel Sambuc namespace dr304 { // dr304: yes 72*0a6a1f1dSLionel Sambuc typedef int &a; 73*0a6a1f1dSLionel Sambuc int n = a(); // expected-error {{requires an initializer}} 74*0a6a1f1dSLionel Sambuc 75*0a6a1f1dSLionel Sambuc struct S { int &b; }; 76*0a6a1f1dSLionel Sambuc int m = S().b; 77*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 78*0a6a1f1dSLionel Sambuc // expected-error@-3 {{requires an initializer}} 79*0a6a1f1dSLionel Sambuc // expected-note@-3 {{in value-initialization}} 80*0a6a1f1dSLionel Sambuc #else 81*0a6a1f1dSLionel Sambuc // expected-error@-5 {{deleted}} 82*0a6a1f1dSLionel Sambuc // expected-note@-7 {{reference}} 83*0a6a1f1dSLionel Sambuc #endif 84*0a6a1f1dSLionel Sambuc } 85*0a6a1f1dSLionel Sambuc 86*0a6a1f1dSLionel Sambuc namespace dr305 { // dr305: no 87*0a6a1f1dSLionel Sambuc struct A { 88*0a6a1f1dSLionel Sambuc typedef A C; 89*0a6a1f1dSLionel Sambuc }; f(A * a)90*0a6a1f1dSLionel Sambuc void f(A *a) { 91*0a6a1f1dSLionel Sambuc struct A {}; 92*0a6a1f1dSLionel Sambuc a->~A(); 93*0a6a1f1dSLionel Sambuc a->~C(); 94*0a6a1f1dSLionel Sambuc } 95*0a6a1f1dSLionel Sambuc typedef A B; g(B * b)96*0a6a1f1dSLionel Sambuc void g(B *b) { 97*0a6a1f1dSLionel Sambuc b->~B(); 98*0a6a1f1dSLionel Sambuc b->~C(); 99*0a6a1f1dSLionel Sambuc } h(B * b)100*0a6a1f1dSLionel Sambuc void h(B *b) { 101*0a6a1f1dSLionel Sambuc struct B {}; // expected-note {{declared here}} 102*0a6a1f1dSLionel Sambuc b->~B(); // expected-error {{does not match}} 103*0a6a1f1dSLionel Sambuc } 104*0a6a1f1dSLionel Sambuc 105*0a6a1f1dSLionel Sambuc template<typename T> struct X {}; i(X<int> * x)106*0a6a1f1dSLionel Sambuc void i(X<int>* x) { 107*0a6a1f1dSLionel Sambuc struct X {}; 108*0a6a1f1dSLionel Sambuc x->~X<int>(); 109*0a6a1f1dSLionel Sambuc x->~X(); 110*0a6a1f1dSLionel Sambuc x->~X<char>(); // expected-error {{no member named}} 111*0a6a1f1dSLionel Sambuc } 112*0a6a1f1dSLionel Sambuc 113*0a6a1f1dSLionel Sambuc // FIXME: This appears to be valid (but allowing the nested types might be a 114*0a6a1f1dSLionel Sambuc // defect). 115*0a6a1f1dSLionel Sambuc template<typename> struct Nested { 116*0a6a1f1dSLionel Sambuc template<typename> struct Nested {}; 117*0a6a1f1dSLionel Sambuc }; testNested(Nested<int> n)118*0a6a1f1dSLionel Sambuc void testNested(Nested<int> n) { n.~Nested<int>(); } // expected-error {{no member named}} 119*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 120*0a6a1f1dSLionel Sambuc // expected-error@-2 {{ambiguous}} 121*0a6a1f1dSLionel Sambuc // expected-note@-6 {{here}} 122*0a6a1f1dSLionel Sambuc // expected-note@-6 {{here}} 123*0a6a1f1dSLionel Sambuc #endif 124*0a6a1f1dSLionel Sambuc 125*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L 126*0a6a1f1dSLionel Sambuc struct Y { 127*0a6a1f1dSLionel Sambuc template<typename T> using T1 = Y; 128*0a6a1f1dSLionel Sambuc }; 129*0a6a1f1dSLionel Sambuc template<typename T> using T2 = Y; j(Y * y)130*0a6a1f1dSLionel Sambuc void j(Y *y) { 131*0a6a1f1dSLionel Sambuc y->~T1<int>(); 132*0a6a1f1dSLionel Sambuc y->~T2<int>(); 133*0a6a1f1dSLionel Sambuc } 134*0a6a1f1dSLionel Sambuc struct Z { 135*0a6a1f1dSLionel Sambuc template<typename T> using T2 = T; 136*0a6a1f1dSLionel Sambuc }; k(Z * z)137*0a6a1f1dSLionel Sambuc void k(Z *z) { 138*0a6a1f1dSLionel Sambuc // FIXME: This diagnostic is terrible. 139*0a6a1f1dSLionel Sambuc z->~T1<int>(); // expected-error {{'T1' following the 'template' keyword does not refer to a template}} expected-error +{{}} 140*0a6a1f1dSLionel Sambuc z->~T2<int>(); // expected-error {{no member named '~int'}} 141*0a6a1f1dSLionel Sambuc z->~T2<Z>(); 142*0a6a1f1dSLionel Sambuc } 143*0a6a1f1dSLionel Sambuc 144*0a6a1f1dSLionel Sambuc // FIXME: This is valid. 145*0a6a1f1dSLionel Sambuc namespace Q { 146*0a6a1f1dSLionel Sambuc template<typename A> struct R {}; 147*0a6a1f1dSLionel Sambuc } 148*0a6a1f1dSLionel Sambuc template<typename A> using R = Q::R<int>; qr(Q::R<int> x)149*0a6a1f1dSLionel Sambuc void qr(Q::R<int> x) { x.~R<char>(); } // expected-error {{no member named}} 150*0a6a1f1dSLionel Sambuc #endif 151*0a6a1f1dSLionel Sambuc } 152*0a6a1f1dSLionel Sambuc 153*0a6a1f1dSLionel Sambuc namespace dr306 { // dr306: no 154*0a6a1f1dSLionel Sambuc // FIXME: dup 39 155*0a6a1f1dSLionel Sambuc // FIXME: This should be accepted. 156*0a6a1f1dSLionel Sambuc struct A { struct B {}; }; // expected-note 2{{member}} 157*0a6a1f1dSLionel Sambuc struct C { typedef A::B B; }; // expected-note {{member}} 158*0a6a1f1dSLionel Sambuc struct D : A, A::B, C {}; 159*0a6a1f1dSLionel Sambuc D::B b; // expected-error {{found in multiple base classes of different types}} 160*0a6a1f1dSLionel Sambuc } 161*0a6a1f1dSLionel Sambuc 162*0a6a1f1dSLionel Sambuc // dr307: na 163*0a6a1f1dSLionel Sambuc 164*0a6a1f1dSLionel Sambuc namespace dr308 { // dr308: yes 165*0a6a1f1dSLionel Sambuc // This is mostly an ABI library issue. 166*0a6a1f1dSLionel Sambuc struct A {}; 167*0a6a1f1dSLionel Sambuc struct B : A {}; 168*0a6a1f1dSLionel Sambuc struct C : A {}; 169*0a6a1f1dSLionel Sambuc struct D : B, C {}; f()170*0a6a1f1dSLionel Sambuc void f() { 171*0a6a1f1dSLionel Sambuc try { 172*0a6a1f1dSLionel Sambuc throw D(); 173*0a6a1f1dSLionel Sambuc } catch (const A&) { 174*0a6a1f1dSLionel Sambuc // unreachable 175*0a6a1f1dSLionel Sambuc } catch (const B&) { 176*0a6a1f1dSLionel Sambuc // get here instead 177*0a6a1f1dSLionel Sambuc } 178*0a6a1f1dSLionel Sambuc } 179*0a6a1f1dSLionel Sambuc } 180*0a6a1f1dSLionel Sambuc 181*0a6a1f1dSLionel Sambuc // dr309: dup 485 182*0a6a1f1dSLionel Sambuc 183*0a6a1f1dSLionel Sambuc namespace dr311 { // dr311: yes 184*0a6a1f1dSLionel Sambuc namespace X { namespace Y {} } 185*0a6a1f1dSLionel Sambuc namespace X::Y {} 186*0a6a1f1dSLionel Sambuc #if __cplusplus <= 201402L 187*0a6a1f1dSLionel Sambuc // expected-error@-2 {{define each namespace separately}} 188*0a6a1f1dSLionel Sambuc #endif 189*0a6a1f1dSLionel Sambuc namespace X { 190*0a6a1f1dSLionel Sambuc namespace X::Y {} 191*0a6a1f1dSLionel Sambuc #if __cplusplus <= 201402L 192*0a6a1f1dSLionel Sambuc // expected-error@-2 {{define each namespace separately}} 193*0a6a1f1dSLionel Sambuc #endif 194*0a6a1f1dSLionel Sambuc } 195*0a6a1f1dSLionel Sambuc // FIXME: The diagnostics here are not very good. 196*0a6a1f1dSLionel Sambuc namespace ::dr311::X {} // expected-error 2+{{}} // expected-warning {{extra qual}} 197*0a6a1f1dSLionel Sambuc } 198*0a6a1f1dSLionel Sambuc 199*0a6a1f1dSLionel Sambuc // dr312: dup 616 200*0a6a1f1dSLionel Sambuc 201*0a6a1f1dSLionel Sambuc namespace dr313 { // dr313: dup 299 c++11 202*0a6a1f1dSLionel Sambuc struct A { operator int() const; }; 203*0a6a1f1dSLionel Sambuc int *p = new int[A()]; 204*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 205*0a6a1f1dSLionel Sambuc // FIXME: should this be available in c++98 mode? expected-error@-2 {{extension}} 206*0a6a1f1dSLionel Sambuc #endif 207*0a6a1f1dSLionel Sambuc } 208*0a6a1f1dSLionel Sambuc 209*0a6a1f1dSLionel Sambuc namespace dr314 { // FIXME 314: dup 1710 210*0a6a1f1dSLionel Sambuc template<typename T> struct A { 211*0a6a1f1dSLionel Sambuc template<typename U> struct B {}; 212*0a6a1f1dSLionel Sambuc }; 213*0a6a1f1dSLionel Sambuc template<typename T> struct C : public A<T>::template B<T> { 214*0a6a1f1dSLionel Sambuc C() : A<T>::template B<T>() {} 215*0a6a1f1dSLionel Sambuc }; 216*0a6a1f1dSLionel Sambuc } 217*0a6a1f1dSLionel Sambuc 218*0a6a1f1dSLionel Sambuc // dr315: na 219*0a6a1f1dSLionel Sambuc // dr316: sup 1004 220*0a6a1f1dSLionel Sambuc 221*0a6a1f1dSLionel Sambuc namespace dr317 { // dr317: 3.5 222*0a6a1f1dSLionel Sambuc void f() {} // expected-note {{previous}} 223*0a6a1f1dSLionel Sambuc inline void f(); // expected-error {{inline declaration of 'f' follows non-inline definition}} 224*0a6a1f1dSLionel Sambuc 225*0a6a1f1dSLionel Sambuc int g(); 226*0a6a1f1dSLionel Sambuc int n = g(); 227*0a6a1f1dSLionel Sambuc inline int g() { return 0; } 228*0a6a1f1dSLionel Sambuc 229*0a6a1f1dSLionel Sambuc int h(); 230*0a6a1f1dSLionel Sambuc int m = h(); 231*0a6a1f1dSLionel Sambuc int h() { return 0; } // expected-note {{previous}} 232*0a6a1f1dSLionel Sambuc inline int h(); // expected-error {{inline declaration of 'h' follows non-inline definition}} 233*0a6a1f1dSLionel Sambuc } 234*0a6a1f1dSLionel Sambuc 235*0a6a1f1dSLionel Sambuc namespace dr318 { // dr318: sup 1310 236*0a6a1f1dSLionel Sambuc struct A {}; 237*0a6a1f1dSLionel Sambuc struct A::A a; 238*0a6a1f1dSLionel Sambuc } 239*0a6a1f1dSLionel Sambuc 240*0a6a1f1dSLionel Sambuc namespace dr319 { // dr319: no 241*0a6a1f1dSLionel Sambuc // FIXME: dup dr389 242*0a6a1f1dSLionel Sambuc // FIXME: We don't have a diagnostic for a name with linkage 243*0a6a1f1dSLionel Sambuc // having a type without linkage. 244*0a6a1f1dSLionel Sambuc typedef struct { 245*0a6a1f1dSLionel Sambuc int i; 246*0a6a1f1dSLionel Sambuc } *ps; 247*0a6a1f1dSLionel Sambuc extern "C" void f(ps); 248*0a6a1f1dSLionel Sambuc void g(ps); // FIXME: ill-formed, type 'ps' has no linkage 249*0a6a1f1dSLionel Sambuc 250*0a6a1f1dSLionel Sambuc static enum { e } a1; 251*0a6a1f1dSLionel Sambuc enum { e2 } a2; // FIXME: ill-formed, enum type has no linkage 252*0a6a1f1dSLionel Sambuc 253*0a6a1f1dSLionel Sambuc enum { n1 = 1u }; 254*0a6a1f1dSLionel Sambuc typedef int (*pa)[n1]; 255*0a6a1f1dSLionel Sambuc pa parr; // ok, type has linkage despite using 'n1' 256*0a6a1f1dSLionel Sambuc 257*0a6a1f1dSLionel Sambuc template<typename> struct X {}; 258*0a6a1f1dSLionel Sambuc 259*0a6a1f1dSLionel Sambuc void f() { 260*0a6a1f1dSLionel Sambuc struct A { int n; }; 261*0a6a1f1dSLionel Sambuc extern A a; // FIXME: ill-formed 262*0a6a1f1dSLionel Sambuc X<A> xa; 263*0a6a1f1dSLionel Sambuc 264*0a6a1f1dSLionel Sambuc typedef A B; 265*0a6a1f1dSLionel Sambuc extern B b; // FIXME: ill-formed 266*0a6a1f1dSLionel Sambuc X<B> xb; 267*0a6a1f1dSLionel Sambuc 268*0a6a1f1dSLionel Sambuc const int n = 1; 269*0a6a1f1dSLionel Sambuc typedef int (*C)[n]; 270*0a6a1f1dSLionel Sambuc extern C c; // ok 271*0a6a1f1dSLionel Sambuc X<C> xc; 272*0a6a1f1dSLionel Sambuc } 273*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 274*0a6a1f1dSLionel Sambuc // expected-error@-12 {{uses local type 'A'}} 275*0a6a1f1dSLionel Sambuc // expected-error@-9 {{uses local type 'A'}} 276*0a6a1f1dSLionel Sambuc #endif 277*0a6a1f1dSLionel Sambuc } 278*0a6a1f1dSLionel Sambuc 279*0a6a1f1dSLionel Sambuc namespace dr320 { // dr320: yes 280*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L 281*0a6a1f1dSLionel Sambuc struct X { 282*0a6a1f1dSLionel Sambuc constexpr X() {} 283*0a6a1f1dSLionel Sambuc constexpr X(const X &x) : copies(x.copies + 1) {} 284*0a6a1f1dSLionel Sambuc unsigned copies = 0; 285*0a6a1f1dSLionel Sambuc }; 286*0a6a1f1dSLionel Sambuc constexpr X f(X x) { return x; } 287*0a6a1f1dSLionel Sambuc constexpr unsigned g(X x) { return x.copies; } 288*0a6a1f1dSLionel Sambuc static_assert(f(X()).copies == g(X()) + 1, "expected one extra copy for return value"); 289*0a6a1f1dSLionel Sambuc #endif 290*0a6a1f1dSLionel Sambuc } 291*0a6a1f1dSLionel Sambuc 292*0a6a1f1dSLionel Sambuc namespace dr321 { // dr321: dup 557 293*0a6a1f1dSLionel Sambuc namespace N { 294*0a6a1f1dSLionel Sambuc template<int> struct A { 295*0a6a1f1dSLionel Sambuc template<int> struct B; 296*0a6a1f1dSLionel Sambuc }; 297*0a6a1f1dSLionel Sambuc template<> template<> struct A<0>::B<0>; 298*0a6a1f1dSLionel Sambuc void f(A<0>::B<0>); 299*0a6a1f1dSLionel Sambuc } 300*0a6a1f1dSLionel Sambuc template<> template<> struct N::A<0>::B<0> {}; 301*0a6a1f1dSLionel Sambuc 302*0a6a1f1dSLionel Sambuc template<typename T> void g(T t) { f(t); } 303*0a6a1f1dSLionel Sambuc template void g(N::A<0>::B<0>); 304*0a6a1f1dSLionel Sambuc 305*0a6a1f1dSLionel Sambuc namespace N { 306*0a6a1f1dSLionel Sambuc template<typename> struct I { friend bool operator==(const I&, const I&); }; 307*0a6a1f1dSLionel Sambuc } 308*0a6a1f1dSLionel Sambuc N::I<int> i, j; 309*0a6a1f1dSLionel Sambuc bool x = i == j; 310*0a6a1f1dSLionel Sambuc } 311*0a6a1f1dSLionel Sambuc 312*0a6a1f1dSLionel Sambuc namespace dr322 { // dr322: yes 313*0a6a1f1dSLionel Sambuc struct A { 314*0a6a1f1dSLionel Sambuc template<typename T> operator T&(); 315*0a6a1f1dSLionel Sambuc } a; 316*0a6a1f1dSLionel Sambuc int &r = static_cast<int&>(a); 317*0a6a1f1dSLionel Sambuc int &s = a; 318*0a6a1f1dSLionel Sambuc } 319*0a6a1f1dSLionel Sambuc 320*0a6a1f1dSLionel Sambuc // dr323: no 321*0a6a1f1dSLionel Sambuc 322*0a6a1f1dSLionel Sambuc namespace dr324 { // dr324: yes 323*0a6a1f1dSLionel Sambuc struct S { int n : 1; } s; // expected-note 3{{bit-field is declared here}} 324*0a6a1f1dSLionel Sambuc int &a = s.n; // expected-error {{non-const reference cannot bind to bit-field}} 325*0a6a1f1dSLionel Sambuc int *b = &s.n; // expected-error {{address of bit-field}} 326*0a6a1f1dSLionel Sambuc int &c = (s.n = 0); // expected-error {{non-const reference cannot bind to bit-field}} 327*0a6a1f1dSLionel Sambuc int *d = &(s.n = 0); // expected-error {{address of bit-field}} 328*0a6a1f1dSLionel Sambuc int &e = true ? s.n : s.n; // expected-error {{non-const reference cannot bind to bit-field}} 329*0a6a1f1dSLionel Sambuc int *f = &(true ? s.n : s.n); // expected-error {{address of bit-field}} 330*0a6a1f1dSLionel Sambuc int &g = (void(), s.n); // expected-error {{non-const reference cannot bind to bit-field}} 331*0a6a1f1dSLionel Sambuc int *h = &(void(), s.n); // expected-error {{address of bit-field}} 332*0a6a1f1dSLionel Sambuc int *i = &++s.n; // expected-error {{address of bit-field}} 333*0a6a1f1dSLionel Sambuc } 334*0a6a1f1dSLionel Sambuc 335*0a6a1f1dSLionel Sambuc namespace dr326 { // dr326: yes 336*0a6a1f1dSLionel Sambuc struct S {}; 337*0a6a1f1dSLionel Sambuc int test[__is_trivially_constructible(S, const S&) ? 1 : -1]; 338*0a6a1f1dSLionel Sambuc } 339*0a6a1f1dSLionel Sambuc 340*0a6a1f1dSLionel Sambuc namespace dr327 { // dr327: dup 538 341*0a6a1f1dSLionel Sambuc struct A; 342*0a6a1f1dSLionel Sambuc class A {}; 343*0a6a1f1dSLionel Sambuc 344*0a6a1f1dSLionel Sambuc class B; 345*0a6a1f1dSLionel Sambuc struct B {}; 346*0a6a1f1dSLionel Sambuc } 347*0a6a1f1dSLionel Sambuc 348*0a6a1f1dSLionel Sambuc namespace dr328 { // dr328: yes 349*0a6a1f1dSLionel Sambuc struct A; // expected-note 3{{forward declaration}} 350*0a6a1f1dSLionel Sambuc struct B { A a; }; // expected-error {{incomplete}} 351*0a6a1f1dSLionel Sambuc template<typename> struct C { A a; }; // expected-error {{incomplete}} 352*0a6a1f1dSLionel Sambuc A *p = new A[0]; // expected-error {{incomplete}} 353*0a6a1f1dSLionel Sambuc } 354*0a6a1f1dSLionel Sambuc 355*0a6a1f1dSLionel Sambuc namespace dr329 { // dr329: 3.5 356*0a6a1f1dSLionel Sambuc struct B {}; 357*0a6a1f1dSLionel Sambuc template<typename T> struct A : B { 358*0a6a1f1dSLionel Sambuc friend void f(A a) { g(a); } 359*0a6a1f1dSLionel Sambuc friend void h(A a) { g(a); } // expected-error {{undeclared}} 360*0a6a1f1dSLionel Sambuc friend void i(B b) {} // expected-error {{redefinition}} expected-note {{previous}} 361*0a6a1f1dSLionel Sambuc }; 362*0a6a1f1dSLionel Sambuc A<int> a; 363*0a6a1f1dSLionel Sambuc A<char> b; // expected-note {{instantiation}} 364*0a6a1f1dSLionel Sambuc 365*0a6a1f1dSLionel Sambuc void test() { 366*0a6a1f1dSLionel Sambuc h(a); // expected-note {{instantiation}} 367*0a6a1f1dSLionel Sambuc } 368*0a6a1f1dSLionel Sambuc } 369*0a6a1f1dSLionel Sambuc 370*0a6a1f1dSLionel Sambuc namespace dr331 { // dr331: yes 371*0a6a1f1dSLionel Sambuc struct A { 372*0a6a1f1dSLionel Sambuc A(volatile A&); // expected-note {{candidate}} 373*0a6a1f1dSLionel Sambuc } const a, b(a); // expected-error {{no matching constructor}} 374*0a6a1f1dSLionel Sambuc } 375*0a6a1f1dSLionel Sambuc 376*0a6a1f1dSLionel Sambuc namespace dr332 { // dr332: dup 577 377*0a6a1f1dSLionel Sambuc void f(volatile void); // expected-error {{'void' as parameter must not have type qualifiers}} 378*0a6a1f1dSLionel Sambuc void g(const void); // expected-error {{'void' as parameter must not have type qualifiers}} 379*0a6a1f1dSLionel Sambuc void h(int n, volatile void); // expected-error {{'void' must be the first and only parameter}} 380*0a6a1f1dSLionel Sambuc } 381*0a6a1f1dSLionel Sambuc 382*0a6a1f1dSLionel Sambuc namespace dr333 { // dr333: yes 383*0a6a1f1dSLionel Sambuc int n = 0; 384*0a6a1f1dSLionel Sambuc int f(int(n)); 385*0a6a1f1dSLionel Sambuc int g((int(n))); 386*0a6a1f1dSLionel Sambuc int h = f(g); 387*0a6a1f1dSLionel Sambuc } 388*0a6a1f1dSLionel Sambuc 389*0a6a1f1dSLionel Sambuc namespace dr334 { // dr334: yes 390*0a6a1f1dSLionel Sambuc template<typename T> void f() { 391*0a6a1f1dSLionel Sambuc T x; 392*0a6a1f1dSLionel Sambuc f((x, 123)); 393*0a6a1f1dSLionel Sambuc } 394*0a6a1f1dSLionel Sambuc struct S { 395*0a6a1f1dSLionel Sambuc friend S operator,(S, int); 396*0a6a1f1dSLionel Sambuc friend void f(S); 397*0a6a1f1dSLionel Sambuc }; 398*0a6a1f1dSLionel Sambuc template void f<S>(); 399*0a6a1f1dSLionel Sambuc } 400*0a6a1f1dSLionel Sambuc 401*0a6a1f1dSLionel Sambuc // dr335: no 402*0a6a1f1dSLionel Sambuc 403*0a6a1f1dSLionel Sambuc namespace dr336 { // dr336: yes 404*0a6a1f1dSLionel Sambuc namespace Pre { 405*0a6a1f1dSLionel Sambuc template<class T1> class A { 406*0a6a1f1dSLionel Sambuc template<class T2> class B { 407*0a6a1f1dSLionel Sambuc template<class T3> void mf1(T3); 408*0a6a1f1dSLionel Sambuc void mf2(); 409*0a6a1f1dSLionel Sambuc }; 410*0a6a1f1dSLionel Sambuc }; 411*0a6a1f1dSLionel Sambuc template<> template<class X> class A<int>::B {}; 412*0a6a1f1dSLionel Sambuc template<> template<> template<class T> void A<int>::B<double>::mf1(T t) {} // expected-error {{does not match}} 413*0a6a1f1dSLionel Sambuc template<class Y> template<> void A<Y>::B<double>::mf2() {} // expected-error {{does not refer into a class}} 414*0a6a1f1dSLionel Sambuc } 415*0a6a1f1dSLionel Sambuc namespace Post { 416*0a6a1f1dSLionel Sambuc template<class T1> class A { 417*0a6a1f1dSLionel Sambuc template<class T2> class B { 418*0a6a1f1dSLionel Sambuc template<class T3> void mf1(T3); 419*0a6a1f1dSLionel Sambuc void mf2(); 420*0a6a1f1dSLionel Sambuc }; 421*0a6a1f1dSLionel Sambuc }; 422*0a6a1f1dSLionel Sambuc template<> template<class X> class A<int>::B { 423*0a6a1f1dSLionel Sambuc template<class T> void mf1(T); 424*0a6a1f1dSLionel Sambuc }; 425*0a6a1f1dSLionel Sambuc template<> template<> template<class T> void A<int>::B<double>::mf1(T t) {} 426*0a6a1f1dSLionel Sambuc // FIXME: This diagnostic isn't very good. 427*0a6a1f1dSLionel Sambuc template<class Y> template<> void A<Y>::B<double>::mf2() {} // expected-error {{does not refer into a class}} 428*0a6a1f1dSLionel Sambuc } 429*0a6a1f1dSLionel Sambuc } 430*0a6a1f1dSLionel Sambuc 431*0a6a1f1dSLionel Sambuc namespace dr337 { // dr337: yes 432*0a6a1f1dSLionel Sambuc template<typename T> void f(T (*)[1]); 433*0a6a1f1dSLionel Sambuc template<typename T> int &f(...); 434*0a6a1f1dSLionel Sambuc 435*0a6a1f1dSLionel Sambuc struct A { virtual ~A() = 0; }; 436*0a6a1f1dSLionel Sambuc int &r = f<A>(0); 437*0a6a1f1dSLionel Sambuc 438*0a6a1f1dSLionel Sambuc // FIXME: The language rules here are completely broken. We cannot determine 439*0a6a1f1dSLionel Sambuc // whether an incomplete type is abstract. See DR1640, which will probably 440*0a6a1f1dSLionel Sambuc // supersede this one and remove this rule. 441*0a6a1f1dSLionel Sambuc struct B; 442*0a6a1f1dSLionel Sambuc int &s = f<B>(0); // expected-error {{of type 'void'}} 443*0a6a1f1dSLionel Sambuc struct B { virtual ~B() = 0; }; 444*0a6a1f1dSLionel Sambuc } 445*0a6a1f1dSLionel Sambuc 446*0a6a1f1dSLionel Sambuc namespace dr339 { // dr339: yes 447*0a6a1f1dSLionel Sambuc template <int I> struct A { static const int value = I; }; 448*0a6a1f1dSLionel Sambuc 449*0a6a1f1dSLionel Sambuc char xxx(int); 450*0a6a1f1dSLionel Sambuc char (&xxx(float))[2]; 451*0a6a1f1dSLionel Sambuc 452*0a6a1f1dSLionel Sambuc template<class T> A<sizeof(xxx((T)0))> f(T) {} // expected-note {{candidate}} 453*0a6a1f1dSLionel Sambuc 454*0a6a1f1dSLionel Sambuc void test() { 455*0a6a1f1dSLionel Sambuc A<1> a = f(0); 456*0a6a1f1dSLionel Sambuc A<2> b = f(0.0f); 457*0a6a1f1dSLionel Sambuc A<3> c = f("foo"); // expected-error {{no matching function}} 458*0a6a1f1dSLionel Sambuc } 459*0a6a1f1dSLionel Sambuc 460*0a6a1f1dSLionel Sambuc 461*0a6a1f1dSLionel Sambuc char f(int); 462*0a6a1f1dSLionel Sambuc int f(...); 463*0a6a1f1dSLionel Sambuc 464*0a6a1f1dSLionel Sambuc template <class T> struct conv_int { 465*0a6a1f1dSLionel Sambuc static const bool value = sizeof(f(T())) == 1; 466*0a6a1f1dSLionel Sambuc }; 467*0a6a1f1dSLionel Sambuc 468*0a6a1f1dSLionel Sambuc template <class T> bool conv_int2(A<sizeof(f(T()))> p); 469*0a6a1f1dSLionel Sambuc 470*0a6a1f1dSLionel Sambuc template<typename T> A<sizeof(f(T()))> make_A(); 471*0a6a1f1dSLionel Sambuc 472*0a6a1f1dSLionel Sambuc int a[conv_int<char>::value ? 1 : -1]; 473*0a6a1f1dSLionel Sambuc bool b = conv_int2<char>(A<1>()); 474*0a6a1f1dSLionel Sambuc A<1> c = make_A<char>(); 475*0a6a1f1dSLionel Sambuc } 476*0a6a1f1dSLionel Sambuc 477*0a6a1f1dSLionel Sambuc namespace dr340 { // dr340: yes 478*0a6a1f1dSLionel Sambuc struct A { A(int); }; 479*0a6a1f1dSLionel Sambuc struct B { B(A, A, int); }; 480*0a6a1f1dSLionel Sambuc int x, y; 481*0a6a1f1dSLionel Sambuc B b(A(x), A(y), 3); 482*0a6a1f1dSLionel Sambuc } 483*0a6a1f1dSLionel Sambuc 484*0a6a1f1dSLionel Sambuc namespace dr341 { // dr341: sup 1708 485*0a6a1f1dSLionel Sambuc namespace A { 486*0a6a1f1dSLionel Sambuc int n; 487*0a6a1f1dSLionel Sambuc extern "C" int &dr341_a = n; // expected-note {{previous}} expected-note {{declared with C language linkage here}} 488*0a6a1f1dSLionel Sambuc } 489*0a6a1f1dSLionel Sambuc namespace B { 490*0a6a1f1dSLionel Sambuc extern "C" int &dr341_a = dr341_a; // expected-error {{redefinition}} 491*0a6a1f1dSLionel Sambuc } 492*0a6a1f1dSLionel Sambuc extern "C" void dr341_b(); // expected-note {{declared with C language linkage here}} 493*0a6a1f1dSLionel Sambuc } 494*0a6a1f1dSLionel Sambuc int dr341_a; // expected-error {{declaration of 'dr341_a' in global scope conflicts with declaration with C language linkage}} 495*0a6a1f1dSLionel Sambuc int dr341_b; // expected-error {{declaration of 'dr341_b' in global scope conflicts with declaration with C language linkage}} 496*0a6a1f1dSLionel Sambuc int dr341_c; // expected-note {{declared in global scope here}} 497*0a6a1f1dSLionel Sambuc int dr341_d; // expected-note {{declared in global scope here}} 498*0a6a1f1dSLionel Sambuc namespace dr341 { 499*0a6a1f1dSLionel Sambuc extern "C" int dr341_c; // expected-error {{declaration of 'dr341_c' with C language linkage conflicts with declaration in global scope}} 500*0a6a1f1dSLionel Sambuc extern "C" void dr341_d(); // expected-error {{declaration of 'dr341_d' with C language linkage conflicts with declaration in global scope}} 501*0a6a1f1dSLionel Sambuc 502*0a6a1f1dSLionel Sambuc namespace A { extern "C" int dr341_e; } // expected-note {{previous}} 503*0a6a1f1dSLionel Sambuc namespace B { extern "C" void dr341_e(); } // expected-error {{redefinition of 'dr341_e' as different kind of symbol}} 504*0a6a1f1dSLionel Sambuc } 505*0a6a1f1dSLionel Sambuc 506*0a6a1f1dSLionel Sambuc // dr342: na 507*0a6a1f1dSLionel Sambuc 508*0a6a1f1dSLionel Sambuc namespace dr343 { // FIXME 343: no 509*0a6a1f1dSLionel Sambuc // FIXME: dup 1710 510*0a6a1f1dSLionel Sambuc template<typename T> struct A { 511*0a6a1f1dSLionel Sambuc template<typename U> struct B {}; 512*0a6a1f1dSLionel Sambuc }; 513*0a6a1f1dSLionel Sambuc // FIXME: In these contexts, the 'template' keyword is optional. 514*0a6a1f1dSLionel Sambuc template<typename T> struct C : public A<T>::B<T> { // expected-error {{use 'template'}} 515*0a6a1f1dSLionel Sambuc C() : A<T>::B<T>() {} // expected-error {{use 'template'}} 516*0a6a1f1dSLionel Sambuc }; 517*0a6a1f1dSLionel Sambuc } 518*0a6a1f1dSLionel Sambuc 519*0a6a1f1dSLionel Sambuc namespace dr344 { // dr344: dup 1435 520*0a6a1f1dSLionel Sambuc struct A { inline virtual ~A(); }; 521*0a6a1f1dSLionel Sambuc struct B { friend A::~A(); }; 522*0a6a1f1dSLionel Sambuc } 523*0a6a1f1dSLionel Sambuc 524*0a6a1f1dSLionel Sambuc namespace dr345 { // dr345: yes 525*0a6a1f1dSLionel Sambuc struct A { 526*0a6a1f1dSLionel Sambuc struct X {}; 527*0a6a1f1dSLionel Sambuc int X; // expected-note {{here}} 528*0a6a1f1dSLionel Sambuc }; 529*0a6a1f1dSLionel Sambuc struct B { 530*0a6a1f1dSLionel Sambuc struct X {}; 531*0a6a1f1dSLionel Sambuc }; 532*0a6a1f1dSLionel Sambuc template <class T> void f(T t) { typename T::X x; } // expected-error {{refers to non-type member 'X'}} 533*0a6a1f1dSLionel Sambuc void f(A a, B b) { 534*0a6a1f1dSLionel Sambuc f(b); 535*0a6a1f1dSLionel Sambuc f(a); // expected-note {{instantiation}} 536*0a6a1f1dSLionel Sambuc } 537*0a6a1f1dSLionel Sambuc } 538*0a6a1f1dSLionel Sambuc 539*0a6a1f1dSLionel Sambuc // dr346: na 540*0a6a1f1dSLionel Sambuc 541*0a6a1f1dSLionel Sambuc namespace dr347 { // dr347: yes 542*0a6a1f1dSLionel Sambuc struct base { 543*0a6a1f1dSLionel Sambuc struct nested; 544*0a6a1f1dSLionel Sambuc static int n; 545*0a6a1f1dSLionel Sambuc static void f(); 546*0a6a1f1dSLionel Sambuc void g(); 547*0a6a1f1dSLionel Sambuc }; 548*0a6a1f1dSLionel Sambuc 549*0a6a1f1dSLionel Sambuc struct derived : base {}; 550*0a6a1f1dSLionel Sambuc 551*0a6a1f1dSLionel Sambuc struct derived::nested {}; // expected-error {{no struct named 'nested'}} 552*0a6a1f1dSLionel Sambuc int derived::n; // expected-error {{no member named 'n'}} 553*0a6a1f1dSLionel Sambuc void derived::f() {} // expected-error {{does not match any}} 554*0a6a1f1dSLionel Sambuc void derived::g() {} // expected-error {{does not match any}} 555*0a6a1f1dSLionel Sambuc } 556*0a6a1f1dSLionel Sambuc 557*0a6a1f1dSLionel Sambuc // dr348: na 558*0a6a1f1dSLionel Sambuc 559*0a6a1f1dSLionel Sambuc namespace dr349 { // dr349: no 560*0a6a1f1dSLionel Sambuc struct A { 561*0a6a1f1dSLionel Sambuc template <class T> operator T ***() { 562*0a6a1f1dSLionel Sambuc int ***p = 0; 563*0a6a1f1dSLionel Sambuc return p; // expected-error {{cannot initialize return object of type 'const int ***' with an lvalue of type 'int ***'}} 564*0a6a1f1dSLionel Sambuc } 565*0a6a1f1dSLionel Sambuc }; 566*0a6a1f1dSLionel Sambuc 567*0a6a1f1dSLionel Sambuc // FIXME: This is valid. 568*0a6a1f1dSLionel Sambuc A a; 569*0a6a1f1dSLionel Sambuc const int *const *const *p1 = a; // expected-note {{in instantiation of}} 570*0a6a1f1dSLionel Sambuc 571*0a6a1f1dSLionel Sambuc struct B { 572*0a6a1f1dSLionel Sambuc template <class T> operator T ***() { 573*0a6a1f1dSLionel Sambuc const int ***p = 0; 574*0a6a1f1dSLionel Sambuc return p; 575*0a6a1f1dSLionel Sambuc } 576*0a6a1f1dSLionel Sambuc }; 577*0a6a1f1dSLionel Sambuc 578*0a6a1f1dSLionel Sambuc // FIXME: This is invalid. 579*0a6a1f1dSLionel Sambuc B b; 580*0a6a1f1dSLionel Sambuc const int *const *const *p2 = b; 581*0a6a1f1dSLionel Sambuc } 582*0a6a1f1dSLionel Sambuc 583*0a6a1f1dSLionel Sambuc // dr351: na 584*0a6a1f1dSLionel Sambuc 585*0a6a1f1dSLionel Sambuc namespace dr352 { // dr352: yes 586*0a6a1f1dSLionel Sambuc namespace example1 { 587*0a6a1f1dSLionel Sambuc namespace A { 588*0a6a1f1dSLionel Sambuc enum E {}; 589*0a6a1f1dSLionel Sambuc template<typename R, typename A> void foo(E, R (*)(A)); // expected-note 2{{couldn't infer template argument 'R'}} 590*0a6a1f1dSLionel Sambuc } 591*0a6a1f1dSLionel Sambuc 592*0a6a1f1dSLionel Sambuc template<typename T> void arg(T); 593*0a6a1f1dSLionel Sambuc template<typename T> int arg(T) = delete; // expected-note {{here}} expected-error 0-1{{extension}} 594*0a6a1f1dSLionel Sambuc 595*0a6a1f1dSLionel Sambuc void f(A::E e) { 596*0a6a1f1dSLionel Sambuc foo(e, &arg); // expected-error {{no matching function}} 597*0a6a1f1dSLionel Sambuc 598*0a6a1f1dSLionel Sambuc using A::foo; 599*0a6a1f1dSLionel Sambuc foo<int, int>(e, &arg); // expected-error {{deleted}} 600*0a6a1f1dSLionel Sambuc } 601*0a6a1f1dSLionel Sambuc 602*0a6a1f1dSLionel Sambuc int arg(int); 603*0a6a1f1dSLionel Sambuc 604*0a6a1f1dSLionel Sambuc void g(A::E e) { 605*0a6a1f1dSLionel Sambuc foo(e, &arg); // expected-error {{no matching function}} 606*0a6a1f1dSLionel Sambuc 607*0a6a1f1dSLionel Sambuc using A::foo; 608*0a6a1f1dSLionel Sambuc foo<int, int>(e, &arg); // ok, uses non-template 609*0a6a1f1dSLionel Sambuc } 610*0a6a1f1dSLionel Sambuc } 611*0a6a1f1dSLionel Sambuc 612*0a6a1f1dSLionel Sambuc namespace contexts { 613*0a6a1f1dSLionel Sambuc template<int I> void f1(int (&)[I]); 614*0a6a1f1dSLionel Sambuc template<int I> void f2(int (&)[I+1]); // expected-note {{couldn't infer}} 615*0a6a1f1dSLionel Sambuc template<int I> void f3(int (&)[I+1], int (&)[I]); 616*0a6a1f1dSLionel Sambuc void f() { 617*0a6a1f1dSLionel Sambuc int a[4]; 618*0a6a1f1dSLionel Sambuc int b[3]; 619*0a6a1f1dSLionel Sambuc f1(a); 620*0a6a1f1dSLionel Sambuc f2(a); // expected-error {{no matching function}} 621*0a6a1f1dSLionel Sambuc f3(a, b); 622*0a6a1f1dSLionel Sambuc } 623*0a6a1f1dSLionel Sambuc 624*0a6a1f1dSLionel Sambuc template<int I> struct S {}; 625*0a6a1f1dSLionel Sambuc template<int I> void g1(S<I>); 626*0a6a1f1dSLionel Sambuc template<int I> void g2(S<I+1>); // expected-note {{couldn't infer}} 627*0a6a1f1dSLionel Sambuc template<int I> void g3(S<I+1>, S<I>); 628*0a6a1f1dSLionel Sambuc void g() { 629*0a6a1f1dSLionel Sambuc S<4> a; 630*0a6a1f1dSLionel Sambuc S<3> b; 631*0a6a1f1dSLionel Sambuc g1(a); 632*0a6a1f1dSLionel Sambuc g2(a); // expected-error {{no matching function}} 633*0a6a1f1dSLionel Sambuc g3(a, b); 634*0a6a1f1dSLionel Sambuc } 635*0a6a1f1dSLionel Sambuc 636*0a6a1f1dSLionel Sambuc template<typename T> void h1(T = 0); // expected-note {{couldn't infer}} 637*0a6a1f1dSLionel Sambuc template<typename T> void h2(T, T = 0); 638*0a6a1f1dSLionel Sambuc void h() { 639*0a6a1f1dSLionel Sambuc h1(); // expected-error {{no matching function}} 640*0a6a1f1dSLionel Sambuc h1(0); 641*0a6a1f1dSLionel Sambuc h1<int>(); 642*0a6a1f1dSLionel Sambuc h2(0); 643*0a6a1f1dSLionel Sambuc } 644*0a6a1f1dSLionel Sambuc 645*0a6a1f1dSLionel Sambuc template<typename T> int tmpl(T); 646*0a6a1f1dSLionel Sambuc template<typename R, typename A> void i1(R (*)(A)); // expected-note 3{{couldn't infer}} 647*0a6a1f1dSLionel Sambuc template<typename R, typename A> void i2(R, A, R (*)(A)); // expected-note {{not viable}} 648*0a6a1f1dSLionel Sambuc void i() { 649*0a6a1f1dSLionel Sambuc extern int single(int); 650*0a6a1f1dSLionel Sambuc i1(single); 651*0a6a1f1dSLionel Sambuc i2(0, 0, single); 652*0a6a1f1dSLionel Sambuc 653*0a6a1f1dSLionel Sambuc extern int ambig(float), ambig(int); 654*0a6a1f1dSLionel Sambuc i1(ambig); // expected-error {{no matching function}} 655*0a6a1f1dSLionel Sambuc i2(0, 0, ambig); 656*0a6a1f1dSLionel Sambuc 657*0a6a1f1dSLionel Sambuc extern void no_match(float), no_match(int); 658*0a6a1f1dSLionel Sambuc i1(no_match); // expected-error {{no matching function}} 659*0a6a1f1dSLionel Sambuc i2(0, 0, no_match); // expected-error {{no matching function}} 660*0a6a1f1dSLionel Sambuc 661*0a6a1f1dSLionel Sambuc i1(tmpl); // expected-error {{no matching function}} 662*0a6a1f1dSLionel Sambuc i2(0, 0, tmpl); 663*0a6a1f1dSLionel Sambuc } 664*0a6a1f1dSLionel Sambuc } 665*0a6a1f1dSLionel Sambuc 666*0a6a1f1dSLionel Sambuc template<typename T> struct is_int; 667*0a6a1f1dSLionel Sambuc template<> struct is_int<int> {}; 668*0a6a1f1dSLionel Sambuc 669*0a6a1f1dSLionel Sambuc namespace example2 { 670*0a6a1f1dSLionel Sambuc template<typename T> int f(T (*p)(T)) { is_int<T>(); } 671*0a6a1f1dSLionel Sambuc int g(int); 672*0a6a1f1dSLionel Sambuc int g(char); 673*0a6a1f1dSLionel Sambuc int i = f(g); 674*0a6a1f1dSLionel Sambuc } 675*0a6a1f1dSLionel Sambuc 676*0a6a1f1dSLionel Sambuc namespace example3 { 677*0a6a1f1dSLionel Sambuc template<typename T> int f(T, T (*p)(T)) { is_int<T>(); } 678*0a6a1f1dSLionel Sambuc int g(int); 679*0a6a1f1dSLionel Sambuc char g(char); 680*0a6a1f1dSLionel Sambuc int i = f(1, g); 681*0a6a1f1dSLionel Sambuc } 682*0a6a1f1dSLionel Sambuc 683*0a6a1f1dSLionel Sambuc namespace example4 { 684*0a6a1f1dSLionel Sambuc template <class T> int f(T, T (*p)(T)) { is_int<T>(); } 685*0a6a1f1dSLionel Sambuc char g(char); 686*0a6a1f1dSLionel Sambuc template <class T> T g(T); 687*0a6a1f1dSLionel Sambuc int i = f(1, g); 688*0a6a1f1dSLionel Sambuc } 689*0a6a1f1dSLionel Sambuc 690*0a6a1f1dSLionel Sambuc namespace example5 { 691*0a6a1f1dSLionel Sambuc template<int I> class A {}; 692*0a6a1f1dSLionel Sambuc template<int I> void g(A<I+1>); // expected-note {{couldn't infer}} 693*0a6a1f1dSLionel Sambuc template<int I> void f(A<I>, A<I+1>); 694*0a6a1f1dSLionel Sambuc void h(A<1> a1, A<2> a2) { 695*0a6a1f1dSLionel Sambuc g(a1); // expected-error {{no matching function}} 696*0a6a1f1dSLionel Sambuc g<0>(a1); 697*0a6a1f1dSLionel Sambuc f(a1, a2); 698*0a6a1f1dSLionel Sambuc } 699*0a6a1f1dSLionel Sambuc } 700*0a6a1f1dSLionel Sambuc } 701*0a6a1f1dSLionel Sambuc 702*0a6a1f1dSLionel Sambuc // dr353 needs an IRGen test. 703*0a6a1f1dSLionel Sambuc 704*0a6a1f1dSLionel Sambuc namespace dr354 { // dr354: yes c++11 705*0a6a1f1dSLionel Sambuc // FIXME: Should we allow this in C++98 too? 706*0a6a1f1dSLionel Sambuc struct S {}; 707*0a6a1f1dSLionel Sambuc 708*0a6a1f1dSLionel Sambuc template<int*> struct ptr {}; // expected-note 0-4{{here}} 709*0a6a1f1dSLionel Sambuc ptr<0> p0; 710*0a6a1f1dSLionel Sambuc ptr<(int*)0> p1; 711*0a6a1f1dSLionel Sambuc ptr<(float*)0> p2; 712*0a6a1f1dSLionel Sambuc ptr<(int S::*)0> p3; 713*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 714*0a6a1f1dSLionel Sambuc // expected-error@-5 {{does not refer to any decl}} 715*0a6a1f1dSLionel Sambuc // expected-error@-5 {{does not refer to any decl}} 716*0a6a1f1dSLionel Sambuc // expected-error@-5 {{does not refer to any decl}} 717*0a6a1f1dSLionel Sambuc // expected-error@-5 {{does not refer to any decl}} 718*0a6a1f1dSLionel Sambuc #elif __cplusplus <= 201402L 719*0a6a1f1dSLionel Sambuc // expected-error@-10 {{must be cast}} 720*0a6a1f1dSLionel Sambuc // ok 721*0a6a1f1dSLionel Sambuc // expected-error@-10 {{does not match}} 722*0a6a1f1dSLionel Sambuc // expected-error@-10 {{does not match}} 723*0a6a1f1dSLionel Sambuc #else 724*0a6a1f1dSLionel Sambuc // expected-error@-15 {{conversion from 'int' to 'int *' is not allowed}} 725*0a6a1f1dSLionel Sambuc // ok 726*0a6a1f1dSLionel Sambuc // expected-error@-15 {{'float *' is not implicitly convertible to 'int *'}} 727*0a6a1f1dSLionel Sambuc // expected-error@-15 {{'int dr354::S::*' is not implicitly convertible to 'int *'}} 728*0a6a1f1dSLionel Sambuc #endif 729*0a6a1f1dSLionel Sambuc 730*0a6a1f1dSLionel Sambuc template<int*> int both(); 731*0a6a1f1dSLionel Sambuc template<int> int both(); 732*0a6a1f1dSLionel Sambuc int b0 = both<0>(); 733*0a6a1f1dSLionel Sambuc int b1 = both<(int*)0>(); 734*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 735*0a6a1f1dSLionel Sambuc // expected-error@-2 {{no matching function}} 736*0a6a1f1dSLionel Sambuc // expected-note@-6 {{candidate}} 737*0a6a1f1dSLionel Sambuc // expected-note@-6 {{candidate}} 738*0a6a1f1dSLionel Sambuc #endif 739*0a6a1f1dSLionel Sambuc 740*0a6a1f1dSLionel Sambuc template<int S::*> struct ptr_mem {}; // expected-note 0-4{{here}} 741*0a6a1f1dSLionel Sambuc ptr_mem<0> m0; 742*0a6a1f1dSLionel Sambuc ptr_mem<(int S::*)0> m1; 743*0a6a1f1dSLionel Sambuc ptr_mem<(float S::*)0> m2; 744*0a6a1f1dSLionel Sambuc ptr_mem<(int *)0> m3; 745*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 746*0a6a1f1dSLionel Sambuc // expected-error@-5 {{cannot be converted}} 747*0a6a1f1dSLionel Sambuc // expected-error@-5 {{is not a pointer to member constant}} 748*0a6a1f1dSLionel Sambuc // expected-error@-5 {{cannot be converted}} 749*0a6a1f1dSLionel Sambuc // expected-error@-5 {{cannot be converted}} 750*0a6a1f1dSLionel Sambuc #elif __cplusplus <= 201402L 751*0a6a1f1dSLionel Sambuc // expected-error@-10 {{must be cast}} 752*0a6a1f1dSLionel Sambuc // ok 753*0a6a1f1dSLionel Sambuc // expected-error@-10 {{does not match}} 754*0a6a1f1dSLionel Sambuc // expected-error@-10 {{does not match}} 755*0a6a1f1dSLionel Sambuc #else 756*0a6a1f1dSLionel Sambuc // expected-error@-15 {{conversion from 'int' to 'int dr354::S::*' is not allowed}} 757*0a6a1f1dSLionel Sambuc // ok 758*0a6a1f1dSLionel Sambuc // expected-error@-15 {{'float dr354::S::*' is not implicitly convertible to 'int dr354::S::*'}} 759*0a6a1f1dSLionel Sambuc // expected-error@-15 {{'int *' is not implicitly convertible to 'int dr354::S::*'}} 760*0a6a1f1dSLionel Sambuc #endif 761*0a6a1f1dSLionel Sambuc } 762*0a6a1f1dSLionel Sambuc 763*0a6a1f1dSLionel Sambuc struct dr355_S; // dr355: yes 764*0a6a1f1dSLionel Sambuc struct ::dr355_S {}; // expected-warning {{extra qualification}} 765*0a6a1f1dSLionel Sambuc namespace dr355 { struct ::dr355_S s; } 766*0a6a1f1dSLionel Sambuc 767*0a6a1f1dSLionel Sambuc // dr356: na 768*0a6a1f1dSLionel Sambuc 769*0a6a1f1dSLionel Sambuc namespace dr357 { // dr357: yes 770*0a6a1f1dSLionel Sambuc template<typename T> struct A { 771*0a6a1f1dSLionel Sambuc void f() const; // expected-note {{const qualified}} 772*0a6a1f1dSLionel Sambuc }; 773*0a6a1f1dSLionel Sambuc template<typename T> void A<T>::f() {} // expected-error {{does not match}} 774*0a6a1f1dSLionel Sambuc 775*0a6a1f1dSLionel Sambuc struct B { 776*0a6a1f1dSLionel Sambuc template<typename T> void f(); 777*0a6a1f1dSLionel Sambuc }; 778*0a6a1f1dSLionel Sambuc template<typename T> void B::f() const {} // expected-error {{does not match}} 779*0a6a1f1dSLionel Sambuc } 780*0a6a1f1dSLionel Sambuc 781*0a6a1f1dSLionel Sambuc namespace dr358 { // dr358: yes 782*0a6a1f1dSLionel Sambuc extern "C" void dr358_f(); 783*0a6a1f1dSLionel Sambuc namespace N { 784*0a6a1f1dSLionel Sambuc int var; 785*0a6a1f1dSLionel Sambuc extern "C" void dr358_f() { var = 10; } 786*0a6a1f1dSLionel Sambuc } 787*0a6a1f1dSLionel Sambuc } 788*0a6a1f1dSLionel Sambuc 789*0a6a1f1dSLionel Sambuc namespace dr359 { // dr359: yes 790*0a6a1f1dSLionel Sambuc // Note, the example in the DR is wrong; it doesn't contain an anonymous 791*0a6a1f1dSLionel Sambuc // union. 792*0a6a1f1dSLionel Sambuc struct E { 793*0a6a1f1dSLionel Sambuc union { 794*0a6a1f1dSLionel Sambuc struct { 795*0a6a1f1dSLionel Sambuc int x; 796*0a6a1f1dSLionel Sambuc } s; 797*0a6a1f1dSLionel Sambuc } v; 798*0a6a1f1dSLionel Sambuc 799*0a6a1f1dSLionel Sambuc union { 800*0a6a1f1dSLionel Sambuc struct { // expected-error {{extension}} 801*0a6a1f1dSLionel Sambuc int x; 802*0a6a1f1dSLionel Sambuc } s; 803*0a6a1f1dSLionel Sambuc 804*0a6a1f1dSLionel Sambuc struct S { // expected-error {{types cannot be declared in an anonymous union}} 805*0a6a1f1dSLionel Sambuc int x; 806*0a6a1f1dSLionel Sambuc } t; 807*0a6a1f1dSLionel Sambuc 808*0a6a1f1dSLionel Sambuc union { // expected-error {{extension}} 809*0a6a1f1dSLionel Sambuc int u; 810*0a6a1f1dSLionel Sambuc }; 811*0a6a1f1dSLionel Sambuc }; 812*0a6a1f1dSLionel Sambuc }; 813*0a6a1f1dSLionel Sambuc } 814*0a6a1f1dSLionel Sambuc 815*0a6a1f1dSLionel Sambuc // dr362: na 816*0a6a1f1dSLionel Sambuc // dr363: na 817*0a6a1f1dSLionel Sambuc 818*0a6a1f1dSLionel Sambuc namespace dr364 { // dr364: yes 819*0a6a1f1dSLionel Sambuc struct S { 820*0a6a1f1dSLionel Sambuc static void f(int); 821*0a6a1f1dSLionel Sambuc void f(char); 822*0a6a1f1dSLionel Sambuc }; 823*0a6a1f1dSLionel Sambuc 824*0a6a1f1dSLionel Sambuc void g() { 825*0a6a1f1dSLionel Sambuc S::f('a'); // expected-error {{call to non-static}} 826*0a6a1f1dSLionel Sambuc S::f(0); 827*0a6a1f1dSLionel Sambuc } 828*0a6a1f1dSLionel Sambuc } 829*0a6a1f1dSLionel Sambuc 830*0a6a1f1dSLionel Sambuc #if "foo" // expected-error {{invalid token}} dr366: yes 831*0a6a1f1dSLionel Sambuc #endif 832*0a6a1f1dSLionel Sambuc 833*0a6a1f1dSLionel Sambuc namespace dr367 { // dr367: yes 834*0a6a1f1dSLionel Sambuc // FIXME: These diagnostics are terrible. Don't diagnose an ill-formed global 835*0a6a1f1dSLionel Sambuc // array as being a VLA! 836*0a6a1f1dSLionel Sambuc int a[true ? throw 0 : 4]; // expected-error 2{{variable length array}} 837*0a6a1f1dSLionel Sambuc int b[true ? 4 : throw 0]; 838*0a6a1f1dSLionel Sambuc int c[true ? *new int : 4]; // expected-error 2{{variable length array}} 839*0a6a1f1dSLionel Sambuc int d[true ? 4 : *new int]; 840*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 841*0a6a1f1dSLionel Sambuc // expected-error@-4 {{variable length array}} expected-error@-4 {{constant expression}} 842*0a6a1f1dSLionel Sambuc // expected-error@-3 {{variable length array}} expected-error@-3 {{constant expression}} 843*0a6a1f1dSLionel Sambuc #endif 844*0a6a1f1dSLionel Sambuc } 845*0a6a1f1dSLionel Sambuc 846*0a6a1f1dSLionel Sambuc namespace dr368 { // dr368: yes 847*0a6a1f1dSLionel Sambuc template<typename T, T> struct S {}; // expected-note {{here}} 848*0a6a1f1dSLionel Sambuc template<typename T> int f(S<T, T()> *); // expected-error {{function type}} 849*0a6a1f1dSLionel Sambuc //template<typename T> int g(S<T, (T())> *); // FIXME: crashes clang 850*0a6a1f1dSLionel Sambuc template<typename T> int g(S<T, true ? T() : T()> *); // expected-note {{cannot have type 'dr368::X'}} 851*0a6a1f1dSLionel Sambuc struct X {}; 852*0a6a1f1dSLionel Sambuc int n = g<X>(0); // expected-error {{no matching}} 853*0a6a1f1dSLionel Sambuc } 854*0a6a1f1dSLionel Sambuc 855*0a6a1f1dSLionel Sambuc // dr370: na 856*0a6a1f1dSLionel Sambuc 857*0a6a1f1dSLionel Sambuc namespace dr372 { // dr372: no 858*0a6a1f1dSLionel Sambuc namespace example1 { 859*0a6a1f1dSLionel Sambuc template<typename T> struct X { 860*0a6a1f1dSLionel Sambuc protected: 861*0a6a1f1dSLionel Sambuc typedef T Type; // expected-note 2{{protected}} 862*0a6a1f1dSLionel Sambuc }; 863*0a6a1f1dSLionel Sambuc template<typename T> struct Y {}; 864*0a6a1f1dSLionel Sambuc 865*0a6a1f1dSLionel Sambuc // FIXME: These two are valid; deriving from T1<T> gives Z1 access to 866*0a6a1f1dSLionel Sambuc // the protected member T1<T>::Type. 867*0a6a1f1dSLionel Sambuc template<typename T, 868*0a6a1f1dSLionel Sambuc template<typename> class T1, 869*0a6a1f1dSLionel Sambuc template<typename> class T2> struct Z1 : 870*0a6a1f1dSLionel Sambuc T1<T>, 871*0a6a1f1dSLionel Sambuc T2<typename T1<T>::Type> {}; // expected-error {{protected}} 872*0a6a1f1dSLionel Sambuc 873*0a6a1f1dSLionel Sambuc template<typename T, 874*0a6a1f1dSLionel Sambuc template<typename> class T1, 875*0a6a1f1dSLionel Sambuc template<typename> class T2> struct Z2 : 876*0a6a1f1dSLionel Sambuc T2<typename T1<T>::Type>, // expected-error {{protected}} 877*0a6a1f1dSLionel Sambuc T1<T> {}; 878*0a6a1f1dSLionel Sambuc 879*0a6a1f1dSLionel Sambuc Z1<int, X, Y> z1; // expected-note {{instantiation of}} 880*0a6a1f1dSLionel Sambuc Z2<int, X, Y> z2; // expected-note {{instantiation of}} 881*0a6a1f1dSLionel Sambuc } 882*0a6a1f1dSLionel Sambuc 883*0a6a1f1dSLionel Sambuc namespace example2 { 884*0a6a1f1dSLionel Sambuc struct X { 885*0a6a1f1dSLionel Sambuc private: 886*0a6a1f1dSLionel Sambuc typedef int Type; // expected-note {{private}} 887*0a6a1f1dSLionel Sambuc }; 888*0a6a1f1dSLionel Sambuc template<typename T> struct A { 889*0a6a1f1dSLionel Sambuc typename T::Type t; // expected-error {{private}} 890*0a6a1f1dSLionel Sambuc }; 891*0a6a1f1dSLionel Sambuc A<X> ax; // expected-note {{instantiation of}} 892*0a6a1f1dSLionel Sambuc } 893*0a6a1f1dSLionel Sambuc 894*0a6a1f1dSLionel Sambuc namespace example3 { 895*0a6a1f1dSLionel Sambuc struct A { 896*0a6a1f1dSLionel Sambuc protected: 897*0a6a1f1dSLionel Sambuc typedef int N; // expected-note 2{{protected}} 898*0a6a1f1dSLionel Sambuc }; 899*0a6a1f1dSLionel Sambuc 900*0a6a1f1dSLionel Sambuc template<typename T> struct B {}; 901*0a6a1f1dSLionel Sambuc template<typename U> struct C : U, B<typename U::N> {}; // expected-error {{protected}} 902*0a6a1f1dSLionel Sambuc template<typename U> struct D : B<typename U::N>, U {}; // expected-error {{protected}} 903*0a6a1f1dSLionel Sambuc 904*0a6a1f1dSLionel Sambuc C<A> x; // expected-note {{instantiation of}} 905*0a6a1f1dSLionel Sambuc D<A> y; // expected-note {{instantiation of}} 906*0a6a1f1dSLionel Sambuc } 907*0a6a1f1dSLionel Sambuc 908*0a6a1f1dSLionel Sambuc namespace example4 { 909*0a6a1f1dSLionel Sambuc class A { 910*0a6a1f1dSLionel Sambuc class B {}; 911*0a6a1f1dSLionel Sambuc friend class X; 912*0a6a1f1dSLionel Sambuc }; 913*0a6a1f1dSLionel Sambuc 914*0a6a1f1dSLionel Sambuc struct X : A::B { 915*0a6a1f1dSLionel Sambuc A::B mx; 916*0a6a1f1dSLionel Sambuc class Y { 917*0a6a1f1dSLionel Sambuc A::B my; 918*0a6a1f1dSLionel Sambuc }; 919*0a6a1f1dSLionel Sambuc }; 920*0a6a1f1dSLionel Sambuc } 921*0a6a1f1dSLionel Sambuc } 922*0a6a1f1dSLionel Sambuc 923*0a6a1f1dSLionel Sambuc namespace dr373 { // dr373: no 924*0a6a1f1dSLionel Sambuc // FIXME: This is valid. 925*0a6a1f1dSLionel Sambuc namespace X { int dr373; } // expected-note 2{{here}} 926*0a6a1f1dSLionel Sambuc struct dr373 { // expected-note {{here}} 927*0a6a1f1dSLionel Sambuc void f() { 928*0a6a1f1dSLionel Sambuc using namespace dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} 929*0a6a1f1dSLionel Sambuc int k = dr373; // expected-error {{does not refer to a value}} 930*0a6a1f1dSLionel Sambuc 931*0a6a1f1dSLionel Sambuc namespace Y = dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} 932*0a6a1f1dSLionel Sambuc k = Y::dr373; 933*0a6a1f1dSLionel Sambuc } 934*0a6a1f1dSLionel Sambuc }; 935*0a6a1f1dSLionel Sambuc } 936*0a6a1f1dSLionel Sambuc 937*0a6a1f1dSLionel Sambuc namespace dr374 { // dr374: yes c++11 938*0a6a1f1dSLionel Sambuc namespace N { 939*0a6a1f1dSLionel Sambuc template<typename T> void f(); 940*0a6a1f1dSLionel Sambuc template<typename T> struct A { void f(); }; 941*0a6a1f1dSLionel Sambuc } 942*0a6a1f1dSLionel Sambuc template<> void N::f<char>() {} 943*0a6a1f1dSLionel Sambuc template<> void N::A<char>::f() {} 944*0a6a1f1dSLionel Sambuc template<> struct N::A<int> {}; 945*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 946*0a6a1f1dSLionel Sambuc // expected-error@-4 {{extension}} expected-note@-7 {{here}} 947*0a6a1f1dSLionel Sambuc // expected-error@-4 {{extension}} expected-note@-7 {{here}} 948*0a6a1f1dSLionel Sambuc // expected-error@-4 {{extension}} expected-note@-8 {{here}} 949*0a6a1f1dSLionel Sambuc #endif 950*0a6a1f1dSLionel Sambuc } 951*0a6a1f1dSLionel Sambuc 952*0a6a1f1dSLionel Sambuc // dr375: dup 345 953*0a6a1f1dSLionel Sambuc // dr376: na 954*0a6a1f1dSLionel Sambuc 955*0a6a1f1dSLionel Sambuc namespace dr377 { // dr377: yes 956*0a6a1f1dSLionel Sambuc enum E { // expected-error {{enumeration values exceed range of largest integer}} 957*0a6a1f1dSLionel Sambuc a = -__LONG_LONG_MAX__ - 1, // expected-error 0-1{{extension}} 958*0a6a1f1dSLionel Sambuc b = 2 * (unsigned long long)__LONG_LONG_MAX__ // expected-error 0-2{{extension}} 959*0a6a1f1dSLionel Sambuc }; 960*0a6a1f1dSLionel Sambuc } 961*0a6a1f1dSLionel Sambuc 962*0a6a1f1dSLionel Sambuc // dr378: dup 276 963*0a6a1f1dSLionel Sambuc // dr379: na 964*0a6a1f1dSLionel Sambuc 965*0a6a1f1dSLionel Sambuc namespace dr381 { // dr381: yes 966*0a6a1f1dSLionel Sambuc struct A { 967*0a6a1f1dSLionel Sambuc int a; 968*0a6a1f1dSLionel Sambuc }; 969*0a6a1f1dSLionel Sambuc struct B : virtual A {}; 970*0a6a1f1dSLionel Sambuc struct C : B {}; 971*0a6a1f1dSLionel Sambuc struct D : B {}; 972*0a6a1f1dSLionel Sambuc struct E : public C, public D {}; 973*0a6a1f1dSLionel Sambuc struct F : public A {}; 974*0a6a1f1dSLionel Sambuc void f() { 975*0a6a1f1dSLionel Sambuc E e; 976*0a6a1f1dSLionel Sambuc e.B::a = 0; // expected-error {{ambiguous conversion}} 977*0a6a1f1dSLionel Sambuc F f; 978*0a6a1f1dSLionel Sambuc f.A::a = 1; 979*0a6a1f1dSLionel Sambuc } 980*0a6a1f1dSLionel Sambuc } 981*0a6a1f1dSLionel Sambuc 982*0a6a1f1dSLionel Sambuc namespace dr382 { // dr382: yes c++11 983*0a6a1f1dSLionel Sambuc // FIXME: Should we allow this in C++98 mode? 984*0a6a1f1dSLionel Sambuc struct A { typedef int T; }; 985*0a6a1f1dSLionel Sambuc typename A::T t; 986*0a6a1f1dSLionel Sambuc typename dr382::A a; 987*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 988*0a6a1f1dSLionel Sambuc // expected-error@-3 {{occurs outside of a template}} 989*0a6a1f1dSLionel Sambuc // expected-error@-3 {{occurs outside of a template}} 990*0a6a1f1dSLionel Sambuc #endif 991*0a6a1f1dSLionel Sambuc typename A b; // expected-error {{expected a qualified name}} 992*0a6a1f1dSLionel Sambuc } 993*0a6a1f1dSLionel Sambuc 994*0a6a1f1dSLionel Sambuc namespace dr383 { // dr383: yes 995*0a6a1f1dSLionel Sambuc struct A { A &operator=(const A&); }; 996*0a6a1f1dSLionel Sambuc struct B { ~B(); }; 997*0a6a1f1dSLionel Sambuc union C { C &operator=(const C&); }; 998*0a6a1f1dSLionel Sambuc union D { ~D(); }; 999*0a6a1f1dSLionel Sambuc int check[(__is_pod(A) || __is_pod(B) || __is_pod(C) || __is_pod(D)) ? -1 : 1]; 1000*0a6a1f1dSLionel Sambuc } 1001*0a6a1f1dSLionel Sambuc 1002*0a6a1f1dSLionel Sambuc namespace dr384 { // dr384: yes 1003*0a6a1f1dSLionel Sambuc namespace N1 { 1004*0a6a1f1dSLionel Sambuc template<typename T> struct Base {}; 1005*0a6a1f1dSLionel Sambuc template<typename T> struct X { 1006*0a6a1f1dSLionel Sambuc struct Y : public Base<T> { 1007*0a6a1f1dSLionel Sambuc Y operator+(int) const; 1008*0a6a1f1dSLionel Sambuc }; 1009*0a6a1f1dSLionel Sambuc Y f(unsigned i) { return Y() + i; } 1010*0a6a1f1dSLionel Sambuc }; 1011*0a6a1f1dSLionel Sambuc } 1012*0a6a1f1dSLionel Sambuc 1013*0a6a1f1dSLionel Sambuc namespace N2 { 1014*0a6a1f1dSLionel Sambuc struct Z {}; 1015*0a6a1f1dSLionel Sambuc template<typename T> int *operator+(T, unsigned); 1016*0a6a1f1dSLionel Sambuc } 1017*0a6a1f1dSLionel Sambuc 1018*0a6a1f1dSLionel Sambuc int main() { 1019*0a6a1f1dSLionel Sambuc N1::X<N2::Z> v; 1020*0a6a1f1dSLionel Sambuc v.f(0); 1021*0a6a1f1dSLionel Sambuc } 1022*0a6a1f1dSLionel Sambuc } 1023*0a6a1f1dSLionel Sambuc 1024*0a6a1f1dSLionel Sambuc namespace dr385 { // dr385: yes 1025*0a6a1f1dSLionel Sambuc struct A { protected: void f(); }; 1026*0a6a1f1dSLionel Sambuc struct B : A { using A::f; }; 1027*0a6a1f1dSLionel Sambuc struct C : A { void g(B b) { b.f(); } }; 1028*0a6a1f1dSLionel Sambuc void h(B b) { b.f(); } 1029*0a6a1f1dSLionel Sambuc 1030*0a6a1f1dSLionel Sambuc struct D { int n; }; // expected-note {{member}} 1031*0a6a1f1dSLionel Sambuc struct E : protected D {}; // expected-note 2{{protected}} 1032*0a6a1f1dSLionel Sambuc struct F : E { friend int i(E); }; 1033*0a6a1f1dSLionel Sambuc int i(E e) { return e.n; } // expected-error {{protected base}} expected-error {{protected member}} 1034*0a6a1f1dSLionel Sambuc } 1035*0a6a1f1dSLionel Sambuc 1036*0a6a1f1dSLionel Sambuc namespace dr387 { // dr387: yes 1037*0a6a1f1dSLionel Sambuc namespace old { 1038*0a6a1f1dSLionel Sambuc template<typename T> class number { 1039*0a6a1f1dSLionel Sambuc number(int); // expected-note 2{{here}} 1040*0a6a1f1dSLionel Sambuc friend number gcd(number &x, number &y) {} 1041*0a6a1f1dSLionel Sambuc }; 1042*0a6a1f1dSLionel Sambuc 1043*0a6a1f1dSLionel Sambuc void g() { 1044*0a6a1f1dSLionel Sambuc number<double> a(3), b(4); // expected-error 2{{private}} 1045*0a6a1f1dSLionel Sambuc a = gcd(a, b); 1046*0a6a1f1dSLionel Sambuc b = gcd(3, 4); // expected-error {{undeclared}} 1047*0a6a1f1dSLionel Sambuc } 1048*0a6a1f1dSLionel Sambuc } 1049*0a6a1f1dSLionel Sambuc 1050*0a6a1f1dSLionel Sambuc namespace newer { 1051*0a6a1f1dSLionel Sambuc template <typename T> class number { 1052*0a6a1f1dSLionel Sambuc public: 1053*0a6a1f1dSLionel Sambuc number(int); 1054*0a6a1f1dSLionel Sambuc friend number gcd(number x, number y) { return 0; } 1055*0a6a1f1dSLionel Sambuc }; 1056*0a6a1f1dSLionel Sambuc 1057*0a6a1f1dSLionel Sambuc void g() { 1058*0a6a1f1dSLionel Sambuc number<double> a(3), b(4); 1059*0a6a1f1dSLionel Sambuc a = gcd(a, b); 1060*0a6a1f1dSLionel Sambuc b = gcd(3, 4); // expected-error {{undeclared}} 1061*0a6a1f1dSLionel Sambuc } 1062*0a6a1f1dSLionel Sambuc } 1063*0a6a1f1dSLionel Sambuc } 1064*0a6a1f1dSLionel Sambuc 1065*0a6a1f1dSLionel Sambuc // FIXME: dr388 needs codegen test 1066*0a6a1f1dSLionel Sambuc 1067*0a6a1f1dSLionel Sambuc namespace dr389 { // dr389: no 1068*0a6a1f1dSLionel Sambuc struct S { 1069*0a6a1f1dSLionel Sambuc typedef struct {} A; 1070*0a6a1f1dSLionel Sambuc typedef enum {} B; 1071*0a6a1f1dSLionel Sambuc typedef struct {} const C; // expected-note 0-2{{here}} 1072*0a6a1f1dSLionel Sambuc typedef enum {} const D; // expected-note 0-1{{here}} 1073*0a6a1f1dSLionel Sambuc }; 1074*0a6a1f1dSLionel Sambuc template<typename> struct T {}; 1075*0a6a1f1dSLionel Sambuc 1076*0a6a1f1dSLionel Sambuc struct WithLinkage1 {}; 1077*0a6a1f1dSLionel Sambuc enum WithLinkage2 {}; 1078*0a6a1f1dSLionel Sambuc typedef struct {} *WithLinkage3a, WithLinkage3b; 1079*0a6a1f1dSLionel Sambuc typedef enum {} WithLinkage4a, *WithLinkage4b; 1080*0a6a1f1dSLionel Sambuc typedef S::A WithLinkage5; 1081*0a6a1f1dSLionel Sambuc typedef const S::B WithLinkage6; 1082*0a6a1f1dSLionel Sambuc typedef int WithLinkage7; 1083*0a6a1f1dSLionel Sambuc typedef void (*WithLinkage8)(WithLinkage2 WithLinkage1::*, WithLinkage5 *); 1084*0a6a1f1dSLionel Sambuc typedef T<WithLinkage5> WithLinkage9; 1085*0a6a1f1dSLionel Sambuc 1086*0a6a1f1dSLionel Sambuc typedef struct {} *WithoutLinkage1; // expected-note 0-1{{here}} 1087*0a6a1f1dSLionel Sambuc typedef enum {} const WithoutLinkage2; // expected-note 0-1{{here}} 1088*0a6a1f1dSLionel Sambuc // These two types don't have linkage even though they are externally visible 1089*0a6a1f1dSLionel Sambuc // and the ODR requires them to be merged across TUs. 1090*0a6a1f1dSLionel Sambuc typedef S::C WithoutLinkage3; 1091*0a6a1f1dSLionel Sambuc typedef S::D WithoutLinkage4; 1092*0a6a1f1dSLionel Sambuc typedef void (*WithoutLinkage5)(int (WithoutLinkage3::*)(char)); 1093*0a6a1f1dSLionel Sambuc 1094*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L 1095*0a6a1f1dSLionel Sambuc // This has linkage even though its template argument does not. 1096*0a6a1f1dSLionel Sambuc // FIXME: This is probably a defect. 1097*0a6a1f1dSLionel Sambuc typedef T<WithoutLinkage1> WithLinkage10; 1098*0a6a1f1dSLionel Sambuc #else 1099*0a6a1f1dSLionel Sambuc typedef int WithLinkage10; // dummy 1100*0a6a1f1dSLionel Sambuc 1101*0a6a1f1dSLionel Sambuc typedef T<WithLinkage1> GoodArg1; 1102*0a6a1f1dSLionel Sambuc typedef T<WithLinkage2> GoodArg2; 1103*0a6a1f1dSLionel Sambuc typedef T<WithLinkage3a> GoodArg3a; 1104*0a6a1f1dSLionel Sambuc typedef T<WithLinkage3b> GoodArg3b; 1105*0a6a1f1dSLionel Sambuc typedef T<WithLinkage4a> GoodArg4a; 1106*0a6a1f1dSLionel Sambuc typedef T<WithLinkage4b> GoodArg4b; 1107*0a6a1f1dSLionel Sambuc typedef T<WithLinkage5> GoodArg5; 1108*0a6a1f1dSLionel Sambuc typedef T<WithLinkage6> GoodArg6; 1109*0a6a1f1dSLionel Sambuc typedef T<WithLinkage7> GoodArg7; 1110*0a6a1f1dSLionel Sambuc typedef T<WithLinkage8> GoodArg8; 1111*0a6a1f1dSLionel Sambuc typedef T<WithLinkage9> GoodArg9; 1112*0a6a1f1dSLionel Sambuc 1113*0a6a1f1dSLionel Sambuc typedef T<WithoutLinkage1> BadArg1; // expected-error{{template argument uses}} 1114*0a6a1f1dSLionel Sambuc typedef T<WithoutLinkage2> BadArg2; // expected-error{{template argument uses}} 1115*0a6a1f1dSLionel Sambuc typedef T<WithoutLinkage3> BadArg3; // expected-error{{template argument uses}} 1116*0a6a1f1dSLionel Sambuc typedef T<WithoutLinkage4> BadArg4; // expected-error{{template argument uses}} 1117*0a6a1f1dSLionel Sambuc typedef T<WithoutLinkage5> BadArg5; // expected-error{{template argument uses}} 1118*0a6a1f1dSLionel Sambuc #endif 1119*0a6a1f1dSLionel Sambuc 1120*0a6a1f1dSLionel Sambuc extern WithLinkage1 withLinkage1; 1121*0a6a1f1dSLionel Sambuc extern WithLinkage2 withLinkage2; 1122*0a6a1f1dSLionel Sambuc extern WithLinkage3a withLinkage3a; 1123*0a6a1f1dSLionel Sambuc extern WithLinkage3b withLinkage3b; 1124*0a6a1f1dSLionel Sambuc extern WithLinkage4a withLinkage4a; 1125*0a6a1f1dSLionel Sambuc extern WithLinkage4b withLinkage4b; 1126*0a6a1f1dSLionel Sambuc extern WithLinkage5 withLinkage5; 1127*0a6a1f1dSLionel Sambuc extern WithLinkage6 withLinkage6; 1128*0a6a1f1dSLionel Sambuc extern WithLinkage7 withLinkage7; 1129*0a6a1f1dSLionel Sambuc extern WithLinkage8 withLinkage8; 1130*0a6a1f1dSLionel Sambuc extern WithLinkage9 withLinkage9; 1131*0a6a1f1dSLionel Sambuc extern WithLinkage10 withLinkage10; 1132*0a6a1f1dSLionel Sambuc 1133*0a6a1f1dSLionel Sambuc // FIXME: These are all ill-formed. 1134*0a6a1f1dSLionel Sambuc extern WithoutLinkage1 withoutLinkage1; 1135*0a6a1f1dSLionel Sambuc extern WithoutLinkage2 withoutLinkage2; 1136*0a6a1f1dSLionel Sambuc extern WithoutLinkage3 withoutLinkage3; 1137*0a6a1f1dSLionel Sambuc extern WithoutLinkage4 withoutLinkage4; 1138*0a6a1f1dSLionel Sambuc extern WithoutLinkage5 withoutLinkage5; 1139*0a6a1f1dSLionel Sambuc 1140*0a6a1f1dSLionel Sambuc // OK, extern "C". 1141*0a6a1f1dSLionel Sambuc extern "C" { 1142*0a6a1f1dSLionel Sambuc extern WithoutLinkage1 dr389_withoutLinkage1; 1143*0a6a1f1dSLionel Sambuc extern WithoutLinkage2 dr389_withoutLinkage2; 1144*0a6a1f1dSLionel Sambuc extern WithoutLinkage3 dr389_withoutLinkage3; 1145*0a6a1f1dSLionel Sambuc extern WithoutLinkage4 dr389_withoutLinkage4; 1146*0a6a1f1dSLionel Sambuc extern WithoutLinkage5 dr389_withoutLinkage5; 1147*0a6a1f1dSLionel Sambuc } 1148*0a6a1f1dSLionel Sambuc 1149*0a6a1f1dSLionel Sambuc // OK, defined. 1150*0a6a1f1dSLionel Sambuc WithoutLinkage1 withoutLinkageDef1; 1151*0a6a1f1dSLionel Sambuc WithoutLinkage2 withoutLinkageDef2 = WithoutLinkage2(); 1152*0a6a1f1dSLionel Sambuc WithoutLinkage3 withoutLinkageDef3 = {}; 1153*0a6a1f1dSLionel Sambuc WithoutLinkage4 withoutLinkageDef4 = WithoutLinkage4(); 1154*0a6a1f1dSLionel Sambuc WithoutLinkage5 withoutLinkageDef5; 1155*0a6a1f1dSLionel Sambuc 1156*0a6a1f1dSLionel Sambuc void use(const void *); 1157*0a6a1f1dSLionel Sambuc void use_all() { 1158*0a6a1f1dSLionel Sambuc use(&withLinkage1); use(&withLinkage2); use(&withLinkage3a); use(&withLinkage3b); 1159*0a6a1f1dSLionel Sambuc use(&withLinkage4a); use(&withLinkage4b); use(&withLinkage5); use(&withLinkage6); 1160*0a6a1f1dSLionel Sambuc use(&withLinkage7); use(&withLinkage8); use(&withLinkage9); use(&withLinkage10); 1161*0a6a1f1dSLionel Sambuc 1162*0a6a1f1dSLionel Sambuc use(&withoutLinkage1); use(&withoutLinkage2); use(&withoutLinkage3); 1163*0a6a1f1dSLionel Sambuc use(&withoutLinkage4); use(&withoutLinkage5); 1164*0a6a1f1dSLionel Sambuc 1165*0a6a1f1dSLionel Sambuc use(&dr389_withoutLinkage1); use(&dr389_withoutLinkage2); 1166*0a6a1f1dSLionel Sambuc use(&dr389_withoutLinkage3); use(&dr389_withoutLinkage4); 1167*0a6a1f1dSLionel Sambuc use(&dr389_withoutLinkage5); 1168*0a6a1f1dSLionel Sambuc 1169*0a6a1f1dSLionel Sambuc use(&withoutLinkageDef1); use(&withoutLinkageDef2); use(&withoutLinkageDef3); 1170*0a6a1f1dSLionel Sambuc use(&withoutLinkageDef4); use(&withoutLinkageDef5); 1171*0a6a1f1dSLionel Sambuc } 1172*0a6a1f1dSLionel Sambuc 1173*0a6a1f1dSLionel Sambuc void local() { 1174*0a6a1f1dSLionel Sambuc // FIXME: This is ill-formed. 1175*0a6a1f1dSLionel Sambuc extern WithoutLinkage1 withoutLinkageLocal; 1176*0a6a1f1dSLionel Sambuc } 1177*0a6a1f1dSLionel Sambuc } 1178*0a6a1f1dSLionel Sambuc 1179*0a6a1f1dSLionel Sambuc namespace dr390 { // dr390: yes 1180*0a6a1f1dSLionel Sambuc template<typename T> 1181*0a6a1f1dSLionel Sambuc struct A { 1182*0a6a1f1dSLionel Sambuc A() { f(); } // expected-warning {{call to pure virt}} 1183*0a6a1f1dSLionel Sambuc virtual void f() = 0; // expected-note {{here}} 1184*0a6a1f1dSLionel Sambuc virtual ~A() = 0; 1185*0a6a1f1dSLionel Sambuc }; 1186*0a6a1f1dSLionel Sambuc template<typename T> A<T>::~A() { T::error; } // expected-error {{cannot be used prior to}} 1187*0a6a1f1dSLionel Sambuc template<typename T> void A<T>::f() { T::error; } // ok, not odr-used 1188*0a6a1f1dSLionel Sambuc struct B : A<int> { // expected-note 2{{in instantiation of}} 1189*0a6a1f1dSLionel Sambuc void f() {} 1190*0a6a1f1dSLionel Sambuc } b; 1191*0a6a1f1dSLionel Sambuc } 1192*0a6a1f1dSLionel Sambuc 1193*0a6a1f1dSLionel Sambuc namespace dr391 { // dr391: yes c++11 1194*0a6a1f1dSLionel Sambuc // FIXME: Should this apply to C++98 too? 1195*0a6a1f1dSLionel Sambuc class A { A(const A&); }; // expected-note 0-1{{here}} 1196*0a6a1f1dSLionel Sambuc A fa(); 1197*0a6a1f1dSLionel Sambuc const A &a = fa(); 1198*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 1199*0a6a1f1dSLionel Sambuc // expected-error@-2 {{C++98 requires an accessible copy constructor}} 1200*0a6a1f1dSLionel Sambuc #endif 1201*0a6a1f1dSLionel Sambuc 1202*0a6a1f1dSLionel Sambuc struct B { B(const B&) = delete; }; // expected-error 0-1{{extension}} expected-note 0-1{{here}} 1203*0a6a1f1dSLionel Sambuc B fb(); 1204*0a6a1f1dSLionel Sambuc const B &b = fb(); 1205*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 1206*0a6a1f1dSLionel Sambuc // expected-error@-2 {{deleted}} 1207*0a6a1f1dSLionel Sambuc #endif 1208*0a6a1f1dSLionel Sambuc 1209*0a6a1f1dSLionel Sambuc template<typename T> 1210*0a6a1f1dSLionel Sambuc struct C { 1211*0a6a1f1dSLionel Sambuc C(const C&) { T::error; } 1212*0a6a1f1dSLionel Sambuc }; 1213*0a6a1f1dSLionel Sambuc C<int> fc(); 1214*0a6a1f1dSLionel Sambuc const C<int> &c = fc(); 1215*0a6a1f1dSLionel Sambuc } 1216*0a6a1f1dSLionel Sambuc 1217*0a6a1f1dSLionel Sambuc // dr392 FIXME write codegen test 1218*0a6a1f1dSLionel Sambuc // dr394: na 1219*0a6a1f1dSLionel Sambuc 1220*0a6a1f1dSLionel Sambuc namespace dr395 { // dr395: yes 1221*0a6a1f1dSLionel Sambuc struct S { 1222*0a6a1f1dSLionel Sambuc template <typename T, int N>(&operator T())[N]; // expected-error {{cannot specify any part of a return type}} 1223*0a6a1f1dSLionel Sambuc template <typename T, int N> operator(T (&)[N])(); // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error +{{}} 1224*0a6a1f1dSLionel Sambuc template <typename T> operator T *() const { return 0; } 1225*0a6a1f1dSLionel Sambuc template <typename T, typename U> operator T U::*() const { return 0; } 1226*0a6a1f1dSLionel Sambuc template <typename T, typename U> operator T (U::*)()() const { return 0; } // expected-error +{{}} 1227*0a6a1f1dSLionel Sambuc }; 1228*0a6a1f1dSLionel Sambuc 1229*0a6a1f1dSLionel Sambuc struct null1_t { 1230*0a6a1f1dSLionel Sambuc template <class T, class U> struct ptr_mem_fun_t { 1231*0a6a1f1dSLionel Sambuc typedef T (U::*type)(); 1232*0a6a1f1dSLionel Sambuc }; 1233*0a6a1f1dSLionel Sambuc 1234*0a6a1f1dSLionel Sambuc template <class T, class U> 1235*0a6a1f1dSLionel Sambuc operator typename ptr_mem_fun_t<T, U>::type() const { // expected-note {{couldn't infer}} 1236*0a6a1f1dSLionel Sambuc return 0; 1237*0a6a1f1dSLionel Sambuc } 1238*0a6a1f1dSLionel Sambuc } null1; 1239*0a6a1f1dSLionel Sambuc int (S::*p)() = null1; // expected-error {{no viable conversion}} 1240*0a6a1f1dSLionel Sambuc 1241*0a6a1f1dSLionel Sambuc template <typename T> using id = T; // expected-error 0-1{{extension}} 1242*0a6a1f1dSLionel Sambuc 1243*0a6a1f1dSLionel Sambuc struct T { 1244*0a6a1f1dSLionel Sambuc template <typename T, int N> operator id<T[N]> &(); 1245*0a6a1f1dSLionel Sambuc template <typename T, typename U> operator id<T (U::*)()>() const; 1246*0a6a1f1dSLionel Sambuc }; 1247*0a6a1f1dSLionel Sambuc 1248*0a6a1f1dSLionel Sambuc struct null2_t { 1249*0a6a1f1dSLionel Sambuc template<class T, class U> using ptr_mem_fun_t = T (U::*)(); // expected-error 0-1{{extension}} 1250*0a6a1f1dSLionel Sambuc template<class T, class U> operator ptr_mem_fun_t<T, U>() const { return 0; }; 1251*0a6a1f1dSLionel Sambuc } null2; 1252*0a6a1f1dSLionel Sambuc int (S::*q)() = null2; 1253*0a6a1f1dSLionel Sambuc } 1254*0a6a1f1dSLionel Sambuc 1255*0a6a1f1dSLionel Sambuc namespace dr396 { // dr396: yes 1256*0a6a1f1dSLionel Sambuc void f() { 1257*0a6a1f1dSLionel Sambuc auto int a(); // expected-error {{storage class on function}} 1258*0a6a1f1dSLionel Sambuc int (i); // expected-note {{previous}} 1259*0a6a1f1dSLionel Sambuc auto int (i); // expected-error {{redefinition}} 1260*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L 1261*0a6a1f1dSLionel Sambuc // expected-error@-4 {{'auto' storage class}} expected-error@-2 {{'auto' storage class}} 1262*0a6a1f1dSLionel Sambuc #endif 1263*0a6a1f1dSLionel Sambuc } 1264*0a6a1f1dSLionel Sambuc } 1265*0a6a1f1dSLionel Sambuc 1266*0a6a1f1dSLionel Sambuc // dr397: sup 1823 1267*0a6a1f1dSLionel Sambuc 1268*0a6a1f1dSLionel Sambuc namespace dr398 { // dr398: yes 1269*0a6a1f1dSLionel Sambuc namespace example1 { 1270*0a6a1f1dSLionel Sambuc struct S { 1271*0a6a1f1dSLionel Sambuc static int const I = 42; 1272*0a6a1f1dSLionel Sambuc }; 1273*0a6a1f1dSLionel Sambuc template <int N> struct X {}; 1274*0a6a1f1dSLionel Sambuc template <typename T> void f(X<T::I> *) {} 1275*0a6a1f1dSLionel Sambuc template <typename T> void f(X<T::J> *) {} 1276*0a6a1f1dSLionel Sambuc void foo() { f<S>(0); } 1277*0a6a1f1dSLionel Sambuc } 1278*0a6a1f1dSLionel Sambuc 1279*0a6a1f1dSLionel Sambuc namespace example2 { 1280*0a6a1f1dSLionel Sambuc template <int I> struct X {}; 1281*0a6a1f1dSLionel Sambuc template <template <class T> class> struct Z {}; 1282*0a6a1f1dSLionel Sambuc template <class T> void f(typename T::Y *) {} // expected-note 2{{substitution failure}} 1283*0a6a1f1dSLionel Sambuc template <class T> void g(X<T::N> *) {} // expected-note {{substitution failure}} 1284*0a6a1f1dSLionel Sambuc template <class T> void h(Z<T::template TT> *) {} // expected-note {{substitution failure}} 1285*0a6a1f1dSLionel Sambuc struct A {}; 1286*0a6a1f1dSLionel Sambuc struct B { 1287*0a6a1f1dSLionel Sambuc int Y; 1288*0a6a1f1dSLionel Sambuc }; 1289*0a6a1f1dSLionel Sambuc struct C { 1290*0a6a1f1dSLionel Sambuc typedef int N; 1291*0a6a1f1dSLionel Sambuc }; 1292*0a6a1f1dSLionel Sambuc struct D { 1293*0a6a1f1dSLionel Sambuc typedef int TT; 1294*0a6a1f1dSLionel Sambuc }; 1295*0a6a1f1dSLionel Sambuc 1296*0a6a1f1dSLionel Sambuc void test() { 1297*0a6a1f1dSLionel Sambuc f<A>(0); // expected-error {{no matching function}} 1298*0a6a1f1dSLionel Sambuc f<B>(0); // expected-error {{no matching function}} 1299*0a6a1f1dSLionel Sambuc g<C>(0); // expected-error {{no matching function}} 1300*0a6a1f1dSLionel Sambuc h<D>(0); // expected-error {{no matching function}} 1301*0a6a1f1dSLionel Sambuc } 1302*0a6a1f1dSLionel Sambuc } 1303*0a6a1f1dSLionel Sambuc } 1304