1*67e74705SXin Li // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 3*67e74705SXin Li // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 4*67e74705SXin Li // RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 5*67e74705SXin Li 6*67e74705SXin Li namespace dr100 { // dr100: yes 7*67e74705SXin Li template<const char *> struct A {}; // expected-note 0-1{{declared here}} 8*67e74705SXin Li template<const char (&)[4]> struct B {}; // expected-note 0-1{{declared here}} 9*67e74705SXin Li A<"foo"> a; // expected-error {{does not refer to any declaration}} 10*67e74705SXin Li B<"bar"> b; // expected-error {{does not refer to any declaration}} 11*67e74705SXin Li } 12*67e74705SXin Li 13*67e74705SXin Li namespace dr101 { // dr101: 3.5 14*67e74705SXin Li extern "C" void dr101_f(); 15*67e74705SXin Li typedef unsigned size_t; 16*67e74705SXin Li namespace X { 17*67e74705SXin Li extern "C" void dr101_f(); 18*67e74705SXin Li typedef unsigned size_t; 19*67e74705SXin Li } 20*67e74705SXin Li using X::dr101_f; 21*67e74705SXin Li using X::size_t; 22*67e74705SXin Li extern "C" void dr101_f(); 23*67e74705SXin Li typedef unsigned size_t; 24*67e74705SXin Li } 25*67e74705SXin Li 26*67e74705SXin Li namespace dr102 { // dr102: yes 27*67e74705SXin Li namespace A { f(T a,T b)28*67e74705SXin Li template<typename T> T f(T a, T b) { return a + b; } // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} 29*67e74705SXin Li } 30*67e74705SXin Li namespace B { 31*67e74705SXin Li struct S {}; 32*67e74705SXin Li } 33*67e74705SXin Li B::S operator+(B::S, B::S); // expected-note {{should be declared prior to the call site or in namespace 'dr102::B'}} 34*67e74705SXin Li template B::S A::f(B::S, B::S); // expected-note {{in instantiation of}} 35*67e74705SXin Li } 36*67e74705SXin Li 37*67e74705SXin Li // dr103: na 38*67e74705SXin Li // dr104 FIXME: add codegen test 39*67e74705SXin Li // dr105: na 40*67e74705SXin Li 41*67e74705SXin Li namespace dr106 { // dr106: sup 540 42*67e74705SXin Li typedef int &r1; 43*67e74705SXin Li typedef r1 &r1; 44*67e74705SXin Li typedef const r1 r1; // expected-warning {{has no effect}} 45*67e74705SXin Li typedef const r1 &r1; // expected-warning {{has no effect}} 46*67e74705SXin Li 47*67e74705SXin Li typedef const int &r2; 48*67e74705SXin Li typedef r2 &r2; 49*67e74705SXin Li typedef const r2 r2; // expected-warning {{has no effect}} 50*67e74705SXin Li typedef const r2 &r2; // expected-warning {{has no effect}} 51*67e74705SXin Li } 52*67e74705SXin Li 53*67e74705SXin Li namespace dr107 { // dr107: yes 54*67e74705SXin Li struct S {}; operator +(S,S)55*67e74705SXin Li extern "C" S operator+(S, S) { return S(); } 56*67e74705SXin Li } 57*67e74705SXin Li 58*67e74705SXin Li namespace dr108 { // dr108: yes 59*67e74705SXin Li template<typename T> struct A { 60*67e74705SXin Li struct B { typedef int X; }; 61*67e74705SXin Li B::X x; // expected-error {{missing 'typename'}} 62*67e74705SXin Li struct C : B { X x; }; // expected-error {{unknown type name}} 63*67e74705SXin Li }; 64*67e74705SXin Li template<> struct A<int>::B { int X; }; 65*67e74705SXin Li } 66*67e74705SXin Li 67*67e74705SXin Li namespace dr109 { // dr109: yes 68*67e74705SXin Li struct A { template<typename T> void f(T); }; 69*67e74705SXin Li template<typename T> struct B : T { 70*67e74705SXin Li using T::template f; // expected-error {{using declaration cannot refer to a template}} gdr109::B71*67e74705SXin Li void g() { this->f<int>(123); } // expected-error {{use 'template'}} 72*67e74705SXin Li }; 73*67e74705SXin Li } 74*67e74705SXin Li 75*67e74705SXin Li namespace dr111 { // dr111: dup 535 76*67e74705SXin Li struct A { A(); A(volatile A&, int = 0); A(A&, const char * = "foo"); }; 77*67e74705SXin Li struct B : A { B(); }; // expected-note +{{would lose const qualifier}} expected-note {{requires 0 arguments}} 78*67e74705SXin Li const B b1; 79*67e74705SXin Li B b2(b1); // expected-error {{no matching constructor}} 80*67e74705SXin Li } 81*67e74705SXin Li 82*67e74705SXin Li namespace dr112 { // dr112: yes 83*67e74705SXin Li struct T { int n; }; 84*67e74705SXin Li typedef T Arr[1]; 85*67e74705SXin Li 86*67e74705SXin Li const T a1[1] = {}; 87*67e74705SXin Li volatile T a2[1] = {}; 88*67e74705SXin Li const Arr a3 = {}; 89*67e74705SXin Li volatile Arr a4 = {}; 90*67e74705SXin Li template<const volatile T*> struct X {}; 91*67e74705SXin Li X<a1> x1; 92*67e74705SXin Li X<a2> x2; 93*67e74705SXin Li X<a3> x3; 94*67e74705SXin Li X<a4> x4; 95*67e74705SXin Li #if __cplusplus < 201103L 96*67e74705SXin Li // expected-error@-5 {{internal linkage}} expected-note@-10 {{here}} 97*67e74705SXin Li // expected-error@-4 {{internal linkage}} expected-note@-9 {{here}} 98*67e74705SXin Li #else 99*67e74705SXin Li // FIXME: Test this somehow. 100*67e74705SXin Li #endif 101*67e74705SXin Li } 102*67e74705SXin Li 103*67e74705SXin Li namespace dr113 { // dr113: yes 104*67e74705SXin Li extern void (*p)(); f()105*67e74705SXin Li void f() { 106*67e74705SXin Li no_such_function(); // expected-error {{undeclared}} 107*67e74705SXin Li p(); 108*67e74705SXin Li } 109*67e74705SXin Li void g(); 110*67e74705SXin Li void (*p)() = &g; 111*67e74705SXin Li } 112*67e74705SXin Li 113*67e74705SXin Li namespace dr114 { // dr114: yes 114*67e74705SXin Li struct A { 115*67e74705SXin Li virtual void f(int) = 0; // expected-note {{unimplemented}} 116*67e74705SXin Li }; 117*67e74705SXin Li struct B : A { 118*67e74705SXin Li template<typename T> void f(T); gdr114::B119*67e74705SXin Li void g() { f(0); } 120*67e74705SXin Li } b; // expected-error {{abstract}} 121*67e74705SXin Li } 122*67e74705SXin Li 123*67e74705SXin Li namespace dr115 { // dr115: yes 124*67e74705SXin Li template<typename T> int f(T); // expected-note +{{}} 125*67e74705SXin Li template<typename T> int g(T); // expected-note +{{}} 126*67e74705SXin Li template<typename T> int g(T, int); // expected-note +{{}} 127*67e74705SXin Li 128*67e74705SXin Li int k1 = f(&f); // expected-error {{no match}} 129*67e74705SXin Li int k2 = f(&f<int>); 130*67e74705SXin Li int k3 = f(&g<int>); // expected-error {{no match}} 131*67e74705SXin Li h()132*67e74705SXin Li void h() { 133*67e74705SXin Li (void)&f; // expected-error {{address of overloaded function 'f' cannot be cast to type 'void'}} 134*67e74705SXin Li (void)&f<int>; 135*67e74705SXin Li (void)&g<int>; // expected-error {{address of overloaded function 'g' cannot be cast to type 'void'}} 136*67e74705SXin Li 137*67e74705SXin Li &f; // expected-error {{reference to overloaded function could not be resolved}} 138*67e74705SXin Li &f<int>; // expected-warning {{unused}} 139*67e74705SXin Li &g<int>; // expected-error {{reference to overloaded function could not be resolved}} 140*67e74705SXin Li } 141*67e74705SXin Li 142*67e74705SXin Li struct S { 143*67e74705SXin Li template<typename T> static int f(T); 144*67e74705SXin Li template<typename T> static int g(T); 145*67e74705SXin Li template<typename T> static int g(T, int); 146*67e74705SXin Li } s; 147*67e74705SXin Li 148*67e74705SXin Li int k4 = f(&s.f); // expected-error {{non-constant pointer to member}} 149*67e74705SXin Li int k5 = f(&s.f<int>); 150*67e74705SXin Li int k6 = f(&s.g<int>); // expected-error {{non-constant pointer to member}} 151*67e74705SXin Li i()152*67e74705SXin Li void i() { 153*67e74705SXin Li (void)&s.f; // expected-error {{non-constant pointer to member}} 154*67e74705SXin Li (void)&s.f<int>; 155*67e74705SXin Li (void)&s.g<int>; // expected-error {{non-constant pointer to member}} 156*67e74705SXin Li 157*67e74705SXin Li &s.f; // expected-error {{non-constant pointer to member}} 158*67e74705SXin Li &s.f<int>; // expected-warning {{unused}} 159*67e74705SXin Li &s.g<int>; // expected-error {{non-constant pointer to member}} 160*67e74705SXin Li } 161*67e74705SXin Li 162*67e74705SXin Li struct T { 163*67e74705SXin Li template<typename T> int f(T); 164*67e74705SXin Li template<typename T> int g(T); 165*67e74705SXin Li template<typename T> int g(T, int); 166*67e74705SXin Li } t; 167*67e74705SXin Li 168*67e74705SXin Li int k7 = f(&s.f); // expected-error {{non-constant pointer to member}} 169*67e74705SXin Li int k8 = f(&s.f<int>); 170*67e74705SXin Li int k9 = f(&s.g<int>); // expected-error {{non-constant pointer to member}} 171*67e74705SXin Li j()172*67e74705SXin Li void j() { 173*67e74705SXin Li (void)&s.f; // expected-error {{non-constant pointer to member}} 174*67e74705SXin Li (void)&s.f<int>; 175*67e74705SXin Li (void)&s.g<int>; // expected-error {{non-constant pointer to member}} 176*67e74705SXin Li 177*67e74705SXin Li &s.f; // expected-error {{non-constant pointer to member}} 178*67e74705SXin Li &s.f<int>; // expected-warning {{unused}} 179*67e74705SXin Li &s.g<int>; // expected-error {{non-constant pointer to member}} 180*67e74705SXin Li } 181*67e74705SXin Li 182*67e74705SXin Li #if __cplusplus >= 201103L 183*67e74705SXin Li // Special case kicks in only if a template argument list is specified. 184*67e74705SXin Li template<typename T=int> void with_default(); // expected-note +{{}} 185*67e74705SXin Li int k10 = f(&with_default); // expected-error {{no matching function}} 186*67e74705SXin Li int k11 = f(&with_default<>); k()187*67e74705SXin Li void k() { 188*67e74705SXin Li (void)&with_default; // expected-error {{overloaded function}} 189*67e74705SXin Li (void)&with_default<>; 190*67e74705SXin Li &with_default; // expected-error {{overloaded function}} 191*67e74705SXin Li &with_default<>; // expected-warning {{unused}} 192*67e74705SXin Li } 193*67e74705SXin Li #endif 194*67e74705SXin Li } 195*67e74705SXin Li 196*67e74705SXin Li namespace dr116 { // dr116: yes 197*67e74705SXin Li template<int> struct A {}; f(A<N>)198*67e74705SXin Li template<int N> void f(A<N>) {} // expected-note {{previous}} f(A<M>)199*67e74705SXin Li template<int M> void f(A<M>) {} // expected-error {{redefinition}} f(A<sizeof (T)>)200*67e74705SXin Li template<typename T> void f(A<sizeof(T)>) {} // expected-note {{previous}} f(A<sizeof (U)>)201*67e74705SXin Li template<typename U> void f(A<sizeof(U)>) {} // expected-error {{redefinition}} 202*67e74705SXin Li } 203*67e74705SXin Li 204*67e74705SXin Li // dr117: na 205*67e74705SXin Li // dr118 FIXME: add codegen test 206*67e74705SXin Li // dr119: na 207*67e74705SXin Li // dr120: na 208*67e74705SXin Li 209*67e74705SXin Li namespace dr121 { // dr121: yes 210*67e74705SXin Li struct X { 211*67e74705SXin Li template<typename T> struct Y {}; 212*67e74705SXin Li }; 213*67e74705SXin Li template<typename T> struct Z { 214*67e74705SXin Li X::Y<T> x; 215*67e74705SXin Li T::Y<T> y; // expected-error +{{}} 216*67e74705SXin Li }; 217*67e74705SXin Li Z<X> z; 218*67e74705SXin Li } 219*67e74705SXin Li 220*67e74705SXin Li namespace dr122 { // dr122: yes 221*67e74705SXin Li template<typename T> void f(); g()222*67e74705SXin Li void g() { f<int>(); } 223*67e74705SXin Li } 224*67e74705SXin Li 225*67e74705SXin Li // dr123: na 226*67e74705SXin Li // dr124: dup 201 227*67e74705SXin Li 228*67e74705SXin Li // dr125: yes 229*67e74705SXin Li struct dr125_A { struct dr125_B {}; }; // expected-note {{here}} 230*67e74705SXin Li dr125_A::dr125_B dr125_C(); 231*67e74705SXin Li namespace dr125_B { dr125_A dr125_C(); } 232*67e74705SXin Li namespace dr125 { 233*67e74705SXin Li struct X { 234*67e74705SXin Li friend dr125_A::dr125_B (::dr125_C)(); // ok 235*67e74705SXin Li friend dr125_A (::dr125_B::dr125_C)(); // ok 236*67e74705SXin Li friend dr125_A::dr125_B::dr125_C(); // expected-error {{did you mean the constructor name 'dr125_B'?}} 237*67e74705SXin Li // expected-error@-1 {{missing exception specification}} 238*67e74705SXin Li #if __cplusplus >= 201103L 239*67e74705SXin Li // expected-error@-3 {{follows constexpr declaration}} expected-note@-10 {{here}} 240*67e74705SXin Li #endif 241*67e74705SXin Li }; 242*67e74705SXin Li } 243*67e74705SXin Li 244*67e74705SXin Li namespace dr126 { // dr126: no 245*67e74705SXin Li struct C {}; 246*67e74705SXin Li struct D : C {}; 247*67e74705SXin Li struct E : private C { friend class A; friend class B; }; 248*67e74705SXin Li struct F : protected C {}; 249*67e74705SXin Li struct G : C {}; 250*67e74705SXin Li struct H : D, G {}; 251*67e74705SXin Li 252*67e74705SXin Li struct A { 253*67e74705SXin Li virtual void cp() throw(C*); 254*67e74705SXin Li virtual void dp() throw(C*); 255*67e74705SXin Li virtual void ep() throw(C*); // expected-note {{overridden}} 256*67e74705SXin Li virtual void fp() throw(C*); // expected-note {{overridden}} 257*67e74705SXin Li virtual void gp() throw(C*); 258*67e74705SXin Li virtual void hp() throw(C*); // expected-note {{overridden}} 259*67e74705SXin Li 260*67e74705SXin Li virtual void cr() throw(C&); 261*67e74705SXin Li virtual void dr() throw(C&); 262*67e74705SXin Li virtual void er() throw(C&); // expected-note {{overridden}} 263*67e74705SXin Li virtual void fr() throw(C&); // expected-note {{overridden}} 264*67e74705SXin Li virtual void gr() throw(C&); 265*67e74705SXin Li virtual void hr() throw(C&); // expected-note {{overridden}} 266*67e74705SXin Li 267*67e74705SXin Li virtual void pv() throw(void*); // expected-note {{overridden}} 268*67e74705SXin Li 269*67e74705SXin Li #if __cplusplus >= 201103L 270*67e74705SXin Li virtual void np() throw(C*); // expected-note {{overridden}} 271*67e74705SXin Li virtual void npm() throw(int C::*); // expected-note {{overridden}} 272*67e74705SXin Li virtual void nr() throw(C&); // expected-note {{overridden}} 273*67e74705SXin Li #endif 274*67e74705SXin Li 275*67e74705SXin Li virtual void ref1() throw(C *const&); 276*67e74705SXin Li virtual void ref2() throw(C *); 277*67e74705SXin Li 278*67e74705SXin Li virtual void v() throw(int); 279*67e74705SXin Li virtual void w() throw(const int); 280*67e74705SXin Li virtual void x() throw(int*); 281*67e74705SXin Li virtual void y() throw(const int*); 282*67e74705SXin Li virtual void z() throw(int); // expected-note {{overridden}} 283*67e74705SXin Li }; 284*67e74705SXin Li struct B : A { 285*67e74705SXin Li virtual void cp() throw(C*); 286*67e74705SXin Li virtual void dp() throw(D*); 287*67e74705SXin Li virtual void ep() throw(E*); // expected-error {{more lax}} 288*67e74705SXin Li virtual void fp() throw(F*); // expected-error {{more lax}} 289*67e74705SXin Li virtual void gp() throw(G*); 290*67e74705SXin Li virtual void hp() throw(H*); // expected-error {{more lax}} 291*67e74705SXin Li 292*67e74705SXin Li virtual void cr() throw(C&); 293*67e74705SXin Li virtual void dr() throw(D&); 294*67e74705SXin Li virtual void er() throw(E&); // expected-error {{more lax}} 295*67e74705SXin Li virtual void fr() throw(F&); // expected-error {{more lax}} 296*67e74705SXin Li virtual void gr() throw(G&); 297*67e74705SXin Li virtual void hr() throw(H&); // expected-error {{more lax}} 298*67e74705SXin Li 299*67e74705SXin Li virtual void pv() throw(C*); // expected-error {{more lax}} FIXME: This is valid. 300*67e74705SXin Li 301*67e74705SXin Li #if __cplusplus >= 201103L 302*67e74705SXin Li using nullptr_t = decltype(nullptr); 303*67e74705SXin Li virtual void np() throw(nullptr_t*); // expected-error {{more lax}} FIXME: This is valid. 304*67e74705SXin Li virtual void npm() throw(nullptr_t*); // expected-error {{more lax}} FIXME: This is valid. 305*67e74705SXin Li virtual void nr() throw(nullptr_t&); // expected-error {{more lax}} This is not. 306*67e74705SXin Li #endif 307*67e74705SXin Li 308*67e74705SXin Li virtual void ref1() throw(D *const &); 309*67e74705SXin Li virtual void ref2() throw(D *); 310*67e74705SXin Li 311*67e74705SXin Li virtual void v() throw(const int); 312*67e74705SXin Li virtual void w() throw(int); 313*67e74705SXin Li virtual void x() throw(const int*); // FIXME: 'const int*' is not allowed by A::h. 314*67e74705SXin Li virtual void y() throw(int*); // ok 315*67e74705SXin Li virtual void z() throw(long); // expected-error {{more lax}} 316*67e74705SXin Li }; 317*67e74705SXin Li } 318*67e74705SXin Li 319*67e74705SXin Li namespace dr127 { // dr127: yes 320*67e74705SXin Li __extension__ typedef __decltype(sizeof(0)) size_t; 321*67e74705SXin Li template<typename T> struct A { 322*67e74705SXin Li A() throw(int); 323*67e74705SXin Li void *operator new(size_t, const char * = 0); operator deletedr127::A324*67e74705SXin Li void operator delete(void *, const char *) { T::error; } // expected-error 2{{no members}} operator deletedr127::A325*67e74705SXin Li void operator delete(void *) { T::error; } 326*67e74705SXin Li }; 327*67e74705SXin Li A<void> *p = new A<void>; // expected-note {{instantiat}} 328*67e74705SXin Li A<int> *q = new ("") A<int>; // expected-note {{instantiat}} 329*67e74705SXin Li } 330*67e74705SXin Li 331*67e74705SXin Li namespace dr128 { // dr128: yes 332*67e74705SXin Li enum E1 { e1 } x = e1; 333*67e74705SXin Li enum E2 { e2 } y = static_cast<E2>(x), z = static_cast<E2>(e1); 334*67e74705SXin Li } 335*67e74705SXin Li 336*67e74705SXin Li // dr129: dup 616 337*67e74705SXin Li // dr130: na 338*67e74705SXin Li 339*67e74705SXin Li namespace dr131 { // dr131: yes 340*67e74705SXin Li const char *a_with_\u0e8c = "\u0e8c"; 341*67e74705SXin Li const char *b_with_\u0e8d = "\u0e8d"; 342*67e74705SXin Li const char *c_with_\u0e8e = "\u0e8e"; 343*67e74705SXin Li #if __cplusplus < 201103L 344*67e74705SXin Li // expected-error@-4 {{expected ';'}} expected-error@-2 {{expected ';'}} 345*67e74705SXin Li #endif 346*67e74705SXin Li } 347*67e74705SXin Li 348*67e74705SXin Li namespace dr132 { // dr132: no f()349*67e74705SXin Li void f() { 350*67e74705SXin Li extern struct {} x; // ok 351*67e74705SXin Li extern struct S {} y; // FIXME: This is invalid. 352*67e74705SXin Li } 353*67e74705SXin Li static enum { E } e; 354*67e74705SXin Li } 355*67e74705SXin Li 356*67e74705SXin Li // dr133: dup 87 357*67e74705SXin Li // dr134: na 358*67e74705SXin Li 359*67e74705SXin Li namespace dr135 { // dr135: yes 360*67e74705SXin Li struct A { fdr135::A361*67e74705SXin Li A f(A a) { return a; } g(A a)362*67e74705SXin Li friend A g(A a) { return a; } hdr135::A363*67e74705SXin Li static A h(A a) { return a; } 364*67e74705SXin Li }; 365*67e74705SXin Li } 366*67e74705SXin Li 367*67e74705SXin Li namespace dr136 { // dr136: 3.4 368*67e74705SXin Li void f(int, int, int = 0); // expected-note {{previous declaration is here}} 369*67e74705SXin Li void g(int, int, int); // expected-note {{previous declaration is here}} 370*67e74705SXin Li struct A { 371*67e74705SXin Li friend void f(int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}} 372*67e74705SXin Li friend void g(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} 373*67e74705SXin Li friend void h(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be a definition}} i(int,int,int=0)374*67e74705SXin Li friend void i(int, int, int = 0) {} // expected-note {{previous declaration is here}} j(int,int,int=0)375*67e74705SXin Li friend void j(int, int, int = 0) {} 376*67e74705SXin Li operator int(); 377*67e74705SXin Li }; 378*67e74705SXin Li void i(int, int, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}} q()379*67e74705SXin Li void q() { 380*67e74705SXin Li j(A(), A()); // ok, has default argument 381*67e74705SXin Li } 382*67e74705SXin Li extern "C" void k(int, int, int, int); // expected-note {{previous declaration is here}} 383*67e74705SXin Li namespace NSA { 384*67e74705SXin Li struct A { 385*67e74705SXin Li friend void dr136::k(int, int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} \ 386*67e74705SXin Li // expected-note {{previous declaration is here}} 387*67e74705SXin Li }; 388*67e74705SXin Li } 389*67e74705SXin Li namespace NSB { 390*67e74705SXin Li struct A { 391*67e74705SXin Li friend void dr136::k(int, int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}} 392*67e74705SXin Li }; 393*67e74705SXin Li } 394*67e74705SXin Li struct B { 395*67e74705SXin Li void f(int); // expected-note {{previous declaration is here}} 396*67e74705SXin Li }; 397*67e74705SXin Li struct C { 398*67e74705SXin Li friend void B::f(int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} 399*67e74705SXin Li }; 400*67e74705SXin Li } 401*67e74705SXin Li 402*67e74705SXin Li namespace dr137 { // dr137: yes 403*67e74705SXin Li extern void *p; 404*67e74705SXin Li extern const void *cp; 405*67e74705SXin Li extern volatile void *vp; 406*67e74705SXin Li extern const volatile void *cvp; 407*67e74705SXin Li int *q = static_cast<int*>(p); 408*67e74705SXin Li int *qc = static_cast<int*>(cp); // expected-error {{casts away qualifiers}} 409*67e74705SXin Li int *qv = static_cast<int*>(vp); // expected-error {{casts away qualifiers}} 410*67e74705SXin Li int *qcv = static_cast<int*>(cvp); // expected-error {{casts away qualifiers}} 411*67e74705SXin Li const int *cq = static_cast<const int*>(p); 412*67e74705SXin Li const int *cqc = static_cast<const int*>(cp); 413*67e74705SXin Li const int *cqv = static_cast<const int*>(vp); // expected-error {{casts away qualifiers}} 414*67e74705SXin Li const int *cqcv = static_cast<const int*>(cvp); // expected-error {{casts away qualifiers}} 415*67e74705SXin Li const volatile int *cvq = static_cast<const volatile int*>(p); 416*67e74705SXin Li const volatile int *cvqc = static_cast<const volatile int*>(cp); 417*67e74705SXin Li const volatile int *cvqv = static_cast<const volatile int*>(vp); 418*67e74705SXin Li const volatile int *cvqcv = static_cast<const volatile int*>(cvp); 419*67e74705SXin Li } 420*67e74705SXin Li 421*67e74705SXin Li namespace dr139 { // dr139: yes 422*67e74705SXin Li namespace example1 { 423*67e74705SXin Li typedef int f; // expected-note {{previous}} 424*67e74705SXin Li struct A { 425*67e74705SXin Li friend void f(A &); // expected-error {{different kind of symbol}} 426*67e74705SXin Li }; 427*67e74705SXin Li } 428*67e74705SXin Li 429*67e74705SXin Li namespace example2 { 430*67e74705SXin Li typedef int f; 431*67e74705SXin Li namespace N { 432*67e74705SXin Li struct A { 433*67e74705SXin Li friend void f(A &); 434*67e74705SXin Li operator int(); gdr139::example2::N::A435*67e74705SXin Li void g(A a) { int i = f(a); } // ok, f is typedef not friend function 436*67e74705SXin Li }; 437*67e74705SXin Li } 438*67e74705SXin Li } 439*67e74705SXin Li } 440*67e74705SXin Li 441*67e74705SXin Li namespace dr140 { // dr140: yes f(int * const)442*67e74705SXin Li void f(int *const) {} // expected-note {{previous}} f(int[3])443*67e74705SXin Li void f(int[3]) {} // expected-error {{redefinition}} 444*67e74705SXin Li void g(const int); g(int n)445*67e74705SXin Li void g(int n) { n = 2; } 446*67e74705SXin Li } 447*67e74705SXin Li 448*67e74705SXin Li namespace dr141 { // dr141: yes 449*67e74705SXin Li template<typename T> void f(); 450*67e74705SXin Li template<typename T> struct S { int n; }; 451*67e74705SXin Li struct A : S<int> { 452*67e74705SXin Li template<typename T> void f(); 453*67e74705SXin Li template<typename T> struct S {}; 454*67e74705SXin Li } a; 455*67e74705SXin Li struct B : S<int> {} b; g()456*67e74705SXin Li void g() { 457*67e74705SXin Li a.f<int>(); 458*67e74705SXin Li (void)a.S<int>::n; // expected-error {{no member named 'n'}} 459*67e74705SXin Li #if __cplusplus < 201103L 460*67e74705SXin Li // expected-error@-2 {{ambiguous}} 461*67e74705SXin Li // expected-note@-11 {{lookup from the current scope}} 462*67e74705SXin Li // expected-note@-9 {{lookup in the object type}} 463*67e74705SXin Li #endif 464*67e74705SXin Li b.f<int>(); // expected-error {{no member}} expected-error +{{}} 465*67e74705SXin Li (void)b.S<int>::n; 466*67e74705SXin Li } 467*67e74705SXin Li template<typename T> struct C { 468*67e74705SXin Li T t; gdr141::C469*67e74705SXin Li void g() { 470*67e74705SXin Li t.f<int>(); // expected-error {{use 'template'}} 471*67e74705SXin Li } hdr141::C472*67e74705SXin Li void h() { 473*67e74705SXin Li (void)t.S<int>::n; // ok 474*67e74705SXin Li } idr141::C475*67e74705SXin Li void i() { 476*67e74705SXin Li (void)t.S<int>(); // ok! 477*67e74705SXin Li } 478*67e74705SXin Li }; h()479*67e74705SXin Li void h() { C<B>().h(); } // ok 480*67e74705SXin Li struct X { 481*67e74705SXin Li template<typename T> void S(); 482*67e74705SXin Li }; i()483*67e74705SXin Li void i() { C<X>().i(); } // ok!! 484*67e74705SXin Li } 485*67e74705SXin Li 486*67e74705SXin Li namespace dr142 { // dr142: yes 487*67e74705SXin Li class B { // expected-note +{{here}} 488*67e74705SXin Li public: 489*67e74705SXin Li int mi; // expected-note +{{here}} 490*67e74705SXin Li static int si; // expected-note +{{here}} 491*67e74705SXin Li }; 492*67e74705SXin Li class D : private B { // expected-note +{{here}} 493*67e74705SXin Li }; 494*67e74705SXin Li class DD : public D { 495*67e74705SXin Li void f(); 496*67e74705SXin Li }; f()497*67e74705SXin Li void DD::f() { 498*67e74705SXin Li mi = 3; // expected-error {{private base class}} expected-error {{private member}} 499*67e74705SXin Li si = 3; // expected-error {{private member}} 500*67e74705SXin Li B b_old; // expected-error {{private member}} 501*67e74705SXin Li dr142::B b; 502*67e74705SXin Li b.mi = 3; 503*67e74705SXin Li b.si = 3; 504*67e74705SXin Li B::si = 3; // expected-error {{private member}} 505*67e74705SXin Li dr142::B::si = 3; 506*67e74705SXin Li B *bp1_old = this; // expected-error {{private member}} expected-error {{private base class}} 507*67e74705SXin Li dr142::B *bp1 = this; // expected-error {{private base class}} 508*67e74705SXin Li B *bp2_old = (B*)this; // expected-error 2{{private member}} 509*67e74705SXin Li dr142::B *bp2 = (dr142::B*)this; 510*67e74705SXin Li bp2->mi = 3; 511*67e74705SXin Li } 512*67e74705SXin Li } 513*67e74705SXin Li 514*67e74705SXin Li namespace dr143 { // dr143: yes 515*67e74705SXin Li namespace A { struct X; } 516*67e74705SXin Li namespace B { void f(A::X); } 517*67e74705SXin Li namespace A { 518*67e74705SXin Li struct X { friend void B::f(X); }; 519*67e74705SXin Li } g(A::X x)520*67e74705SXin Li void g(A::X x) { 521*67e74705SXin Li f(x); // expected-error {{undeclared identifier 'f'}} 522*67e74705SXin Li } 523*67e74705SXin Li } 524*67e74705SXin Li 525*67e74705SXin Li namespace dr145 { // dr145: yes f(bool b)526*67e74705SXin Li void f(bool b) { 527*67e74705SXin Li #if __cplusplus <= 201402L 528*67e74705SXin Li ++b; // expected-warning {{deprecated}} 529*67e74705SXin Li b++; // expected-warning {{deprecated}} 530*67e74705SXin Li #else 531*67e74705SXin Li ++b; // expected-error {{increment}} 532*67e74705SXin Li b++; // expected-error {{increment}} 533*67e74705SXin Li #endif 534*67e74705SXin Li } 535*67e74705SXin Li } 536*67e74705SXin Li 537*67e74705SXin Li namespace dr147 { // dr147: no 538*67e74705SXin Li namespace example1 { 539*67e74705SXin Li template<typename> struct A { 540*67e74705SXin Li template<typename T> A(T); 541*67e74705SXin Li }; 542*67e74705SXin Li // FIXME: This appears to be valid, and EDG and G++ accept. A(int)543*67e74705SXin Li template<> template<> A<int>::A<int>(int) {} // expected-error {{out-of-line constructor for 'A' cannot have template arguments}} 544*67e74705SXin Li } 545*67e74705SXin Li namespace example2 { 546*67e74705SXin Li struct A { A(); }; 547*67e74705SXin Li struct B : A { B(); }; 548*67e74705SXin Li A::A a1; // expected-error {{is a constructor}} 549*67e74705SXin Li B::A a2; 550*67e74705SXin Li } 551*67e74705SXin Li namespace example3 { 552*67e74705SXin Li template<typename> struct A { 553*67e74705SXin Li template<typename T> A(T); 554*67e74705SXin Li static A a; 555*67e74705SXin Li }; 556*67e74705SXin Li template<> A<int>::A<int>(A<int>::a); // expected-error {{is a constructor}} 557*67e74705SXin Li } 558*67e74705SXin Li } 559*67e74705SXin Li 560*67e74705SXin Li namespace dr148 { // dr148: yes 561*67e74705SXin Li struct A { int A::*p; }; 562*67e74705SXin Li int check1[__is_pod(int(A::*)) ? 1 : -1]; 563*67e74705SXin Li int check2[__is_pod(A) ? 1 : -1]; 564*67e74705SXin Li } 565*67e74705SXin Li 566*67e74705SXin Li // dr149: na 567*67e74705SXin Li 568*67e74705SXin Li namespace dr151 { // dr151: yes 569*67e74705SXin Li struct X {}; 570*67e74705SXin Li typedef int X::*p; 571*67e74705SXin Li #if __cplusplus < 201103L 572*67e74705SXin Li #define fold(x) (__builtin_constant_p(0) ? (x) : (x)) 573*67e74705SXin Li #else 574*67e74705SXin Li #define fold 575*67e74705SXin Li #endif 576*67e74705SXin Li int check[fold(p() == 0) ? 1 : -1]; 577*67e74705SXin Li #undef fold 578*67e74705SXin Li } 579*67e74705SXin Li 580*67e74705SXin Li namespace dr152 { // dr152: yes 581*67e74705SXin Li struct A { 582*67e74705SXin Li A(); // expected-note {{not viable}} 583*67e74705SXin Li explicit A(const A&); 584*67e74705SXin Li }; 585*67e74705SXin Li A a1 = A(); // expected-error {{no matching constructor}} 586*67e74705SXin Li A a2((A())); 587*67e74705SXin Li } 588*67e74705SXin Li 589*67e74705SXin Li // dr153: na 590*67e74705SXin Li 591*67e74705SXin Li namespace dr154 { // dr154: yes 592*67e74705SXin Li union { int a; }; // expected-error {{must be declared 'static'}} 593*67e74705SXin Li namespace { 594*67e74705SXin Li union { int b; }; 595*67e74705SXin Li } 596*67e74705SXin Li static union { int c; }; 597*67e74705SXin Li } 598*67e74705SXin Li 599*67e74705SXin Li namespace dr155 { // dr155: dup 632 600*67e74705SXin Li struct S { int n; } s = { { 1 } }; // expected-warning {{braces around scalar initializer}} 601*67e74705SXin Li } 602*67e74705SXin Li 603*67e74705SXin Li // dr158 FIXME write codegen test 604*67e74705SXin Li 605*67e74705SXin Li namespace dr159 { // dr159: 3.5 606*67e74705SXin Li namespace X { void f(); } 607*67e74705SXin Li void f(); f()608*67e74705SXin Li void dr159::f() {} // expected-warning {{extra qualification}} f()609*67e74705SXin Li void dr159::X::f() {} 610*67e74705SXin Li } 611*67e74705SXin Li 612*67e74705SXin Li // dr160: na 613*67e74705SXin Li 614*67e74705SXin Li namespace dr161 { // dr161: yes 615*67e74705SXin Li class A { 616*67e74705SXin Li protected: 617*67e74705SXin Li struct B { int n; } b; // expected-note 2{{here}} 618*67e74705SXin Li static B bs; 619*67e74705SXin Li void f(); // expected-note {{here}} 620*67e74705SXin Li static void sf(); 621*67e74705SXin Li }; 622*67e74705SXin Li struct C : A {}; 623*67e74705SXin Li struct D : A { gdr161::D624*67e74705SXin Li void g(C c) { 625*67e74705SXin Li (void)b.n; 626*67e74705SXin Li B b1; 627*67e74705SXin Li C::B b2; // ok, accessible as a member of A 628*67e74705SXin Li (void)&C::b; // expected-error {{protected}} 629*67e74705SXin Li (void)&C::bs; 630*67e74705SXin Li (void)c.b; // expected-error {{protected}} 631*67e74705SXin Li (void)c.bs; 632*67e74705SXin Li f(); 633*67e74705SXin Li sf(); 634*67e74705SXin Li c.f(); // expected-error {{protected}} 635*67e74705SXin Li c.sf(); 636*67e74705SXin Li A::f(); 637*67e74705SXin Li D::f(); 638*67e74705SXin Li A::sf(); 639*67e74705SXin Li C::sf(); 640*67e74705SXin Li D::sf(); 641*67e74705SXin Li } 642*67e74705SXin Li }; 643*67e74705SXin Li } 644*67e74705SXin Li 645*67e74705SXin Li namespace dr162 { // dr162: no 646*67e74705SXin Li struct A { 647*67e74705SXin Li char &f(char); 648*67e74705SXin Li static int &f(int); 649*67e74705SXin Li gdr162::A650*67e74705SXin Li void g() { 651*67e74705SXin Li int &a = (&A::f)(0); // FIXME: expected-error {{could not be resolved}} 652*67e74705SXin Li char &b = (&A::f)('0'); // expected-error {{could not be resolved}} 653*67e74705SXin Li } 654*67e74705SXin Li }; 655*67e74705SXin Li 656*67e74705SXin Li int &c = (&A::f)(0); // FIXME: expected-error {{could not be resolved}} 657*67e74705SXin Li char &d = (&A::f)('0'); // expected-error {{could not be resolved}} 658*67e74705SXin Li } 659*67e74705SXin Li 660*67e74705SXin Li // dr163: na 661*67e74705SXin Li 662*67e74705SXin Li namespace dr164 { // dr164: yes 663*67e74705SXin Li void f(int); g(T t)664*67e74705SXin Li template <class T> int g(T t) { return f(t); } 665*67e74705SXin Li 666*67e74705SXin Li enum E { e }; 667*67e74705SXin Li int f(E); 668*67e74705SXin Li 669*67e74705SXin Li int k = g(e); 670*67e74705SXin Li } 671*67e74705SXin Li 672*67e74705SXin Li namespace dr165 { // dr165: no 673*67e74705SXin Li namespace N { 674*67e74705SXin Li struct A { friend struct B; }; f()675*67e74705SXin Li void f() { void g(); } 676*67e74705SXin Li } 677*67e74705SXin Li // FIXME: dr1477 says this is ok, dr165 says it's ill-formed 678*67e74705SXin Li struct N::B {}; 679*67e74705SXin Li // FIXME: dr165 says this is ill-formed, but the argument in dr1477 says it's ok g()680*67e74705SXin Li void N::g() {} 681*67e74705SXin Li } 682*67e74705SXin Li 683*67e74705SXin Li namespace dr166 { // dr166: yes 684*67e74705SXin Li namespace A { class X; } 685*67e74705SXin Li f(T t)686*67e74705SXin Li template<typename T> int f(T t) { return t.n; } 687*67e74705SXin Li int g(A::X); h(T t)688*67e74705SXin Li template<typename T> int h(T t) { return t.n; } // expected-error {{private}} 689*67e74705SXin Li int i(A::X); 690*67e74705SXin Li 691*67e74705SXin Li namespace A { 692*67e74705SXin Li class X { 693*67e74705SXin Li friend int f<X>(X); 694*67e74705SXin Li friend int dr166::g(X); 695*67e74705SXin Li friend int h(X); 696*67e74705SXin Li friend int i(X); 697*67e74705SXin Li int n; // expected-note 2{{here}} 698*67e74705SXin Li }; 699*67e74705SXin Li h(X x)700*67e74705SXin Li int h(X x) { return x.n; } i(X x)701*67e74705SXin Li int i(X x) { return x.n; } 702*67e74705SXin Li } 703*67e74705SXin Li 704*67e74705SXin Li template int f(A::X); g(A::X x)705*67e74705SXin Li int g(A::X x) { return x.n; } 706*67e74705SXin Li template int h(A::X); // expected-note {{instantiation}} i(A::X x)707*67e74705SXin Li int i(A::X x) { return x.n; } // expected-error {{private}} 708*67e74705SXin Li } 709*67e74705SXin Li 710*67e74705SXin Li // dr167: sup 1012 711*67e74705SXin Li 712*67e74705SXin Li namespace dr168 { // dr168: no 713*67e74705SXin Li extern "C" typedef int (*p)(); 714*67e74705SXin Li extern "C++" typedef int (*q)(); 715*67e74705SXin Li struct S { 716*67e74705SXin Li static int f(); 717*67e74705SXin Li }; 718*67e74705SXin Li p a = &S::f; // FIXME: this should fail. 719*67e74705SXin Li q b = &S::f; 720*67e74705SXin Li } 721*67e74705SXin Li 722*67e74705SXin Li namespace dr169 { // dr169: yes 723*67e74705SXin Li template<typename> struct A { int n; }; 724*67e74705SXin Li struct B { 725*67e74705SXin Li template<typename> struct C; 726*67e74705SXin Li template<typename> void f(); 727*67e74705SXin Li template<typename> static int n; // expected-error 0-1{{extension}} 728*67e74705SXin Li }; 729*67e74705SXin Li struct D : A<int>, B { 730*67e74705SXin Li using A<int>::n; 731*67e74705SXin Li using B::C<int>; // expected-error {{using declaration cannot refer to a template specialization}} 732*67e74705SXin Li using B::f<int>; // expected-error {{using declaration cannot refer to a template specialization}} 733*67e74705SXin Li using B::n<int>; // expected-error {{using declaration cannot refer to a template specialization}} 734*67e74705SXin Li }; 735*67e74705SXin Li } 736*67e74705SXin Li 737*67e74705SXin Li namespace { // dr171: yes 738*67e74705SXin Li int dr171a; 739*67e74705SXin Li } 740*67e74705SXin Li int dr171b; // expected-note {{here}} 741*67e74705SXin Li namespace dr171 { 742*67e74705SXin Li extern "C" void dr171a(); 743*67e74705SXin Li extern "C" void dr171b(); // expected-error {{conflicts}} 744*67e74705SXin Li } 745*67e74705SXin Li 746*67e74705SXin Li namespace dr172 { // dr172: yes 747*67e74705SXin Li enum { zero }; 748*67e74705SXin Li int check1[-1 < zero ? 1 : -1]; 749*67e74705SXin Li 750*67e74705SXin Li enum { x = -1, y = (unsigned int)-1 }; 751*67e74705SXin Li int check2[sizeof(x) > sizeof(int) ? 1 : -1]; 752*67e74705SXin Li 753*67e74705SXin Li enum { a = (unsigned int)-1 / 2 }; 754*67e74705SXin Li int check3a[sizeof(a) == sizeof(int) ? 1 : -1]; 755*67e74705SXin Li int check3b[-a < 0 ? 1 : -1]; 756*67e74705SXin Li 757*67e74705SXin Li enum { b = (unsigned int)-1 / 2 + 1 }; 758*67e74705SXin Li int check4a[sizeof(b) == sizeof(unsigned int) ? 1 : -1]; 759*67e74705SXin Li int check4b[-b > 0 ? 1 : -1]; 760*67e74705SXin Li 761*67e74705SXin Li enum { c = (unsigned long)-1 / 2 }; 762*67e74705SXin Li int check5a[sizeof(c) == sizeof(long) ? 1 : -1]; 763*67e74705SXin Li int check5b[-c < 0 ? 1 : -1]; 764*67e74705SXin Li 765*67e74705SXin Li enum { d = (unsigned long)-1 / 2 + 1 }; 766*67e74705SXin Li int check6a[sizeof(d) == sizeof(unsigned long) ? 1 : -1]; 767*67e74705SXin Li int check6b[-d > 0 ? 1 : -1]; 768*67e74705SXin Li 769*67e74705SXin Li enum { e = (unsigned long long)-1 / 2 }; // expected-error 0-1{{extension}} 770*67e74705SXin Li int check7a[sizeof(e) == sizeof(long) ? 1 : -1]; // expected-error 0-1{{extension}} 771*67e74705SXin Li int check7b[-e < 0 ? 1 : -1]; 772*67e74705SXin Li 773*67e74705SXin Li enum { f = (unsigned long long)-1 / 2 + 1 }; // expected-error 0-1{{extension}} 774*67e74705SXin Li int check8a[sizeof(f) == sizeof(unsigned long) ? 1 : -1]; // expected-error 0-1{{extension}} 775*67e74705SXin Li int check8b[-f > 0 ? 1 : -1]; 776*67e74705SXin Li } 777*67e74705SXin Li 778*67e74705SXin Li namespace dr173 { // dr173: yes 779*67e74705SXin Li int check[('0' + 1 == '1' && '0' + 2 == '2' && '0' + 3 == '3' && 780*67e74705SXin Li '0' + 4 == '4' && '0' + 5 == '5' && '0' + 6 == '6' && 781*67e74705SXin Li '0' + 7 == '7' && '0' + 8 == '8' && '0' + 9 == '9') ? 1 : -1]; 782*67e74705SXin Li } 783*67e74705SXin Li 784*67e74705SXin Li // dr174: sup 1012 785*67e74705SXin Li 786*67e74705SXin Li namespace dr175 { // dr175: yes 787*67e74705SXin Li struct A {}; // expected-note {{here}} 788*67e74705SXin Li struct B : private A {}; // expected-note {{constrained by private inheritance}} 789*67e74705SXin Li struct C : B { 790*67e74705SXin Li A a; // expected-error {{private}} 791*67e74705SXin Li dr175::A b; 792*67e74705SXin Li }; 793*67e74705SXin Li } 794*67e74705SXin Li 795*67e74705SXin Li namespace dr176 { // dr176: yes 796*67e74705SXin Li template<typename T> class Y; 797*67e74705SXin Li template<> class Y<int> { f()798*67e74705SXin Li void f() { 799*67e74705SXin Li typedef Y A; // expected-note {{here}} 800*67e74705SXin Li typedef Y<char> A; // expected-error {{different types ('Y<char>' vs 'Y<int>')}} 801*67e74705SXin Li } 802*67e74705SXin Li }; 803*67e74705SXin Li 804*67e74705SXin Li template<typename T> struct Base {}; // expected-note 2{{found}} 805*67e74705SXin Li template<typename T> struct Derived : public Base<T> { fdr176::Derived806*67e74705SXin Li void f() { 807*67e74705SXin Li typedef typename Derived::template Base<T> A; 808*67e74705SXin Li typedef typename Derived::Base A; 809*67e74705SXin Li } 810*67e74705SXin Li }; 811*67e74705SXin Li template struct Derived<int>; 812*67e74705SXin Li 813*67e74705SXin Li template<typename T> struct Derived2 : Base<int>, Base<char> { 814*67e74705SXin Li typename Derived2::Base b; // expected-error {{found in multiple base classes}} 815*67e74705SXin Li typename Derived2::Base<double> d; 816*67e74705SXin Li }; 817*67e74705SXin Li 818*67e74705SXin Li template<typename T> class X { // expected-note {{here}} 819*67e74705SXin Li X *p1; 820*67e74705SXin Li X<T> *p2; 821*67e74705SXin Li X<int> *p3; 822*67e74705SXin Li dr176::X *p4; // expected-error {{requires template arguments}} 823*67e74705SXin Li }; 824*67e74705SXin Li } 825*67e74705SXin Li 826*67e74705SXin Li namespace dr177 { // dr177: yes 827*67e74705SXin Li struct B {}; 828*67e74705SXin Li struct A { 829*67e74705SXin Li A(A &); // expected-note {{not viable: expects an l-value}} 830*67e74705SXin Li A(const B &); 831*67e74705SXin Li }; 832*67e74705SXin Li B b; 833*67e74705SXin Li A a = b; // expected-error {{no viable constructor copying variable}} 834*67e74705SXin Li } 835*67e74705SXin Li 836*67e74705SXin Li namespace dr178 { // dr178: yes 837*67e74705SXin Li int check[int() == 0 ? 1 : -1]; 838*67e74705SXin Li #if __cplusplus >= 201103L 839*67e74705SXin Li static_assert(int{} == 0, ""); 840*67e74705SXin Li struct S { int a, b; }; 841*67e74705SXin Li static_assert(S{1}.b == 0, ""); Tdr178::T842*67e74705SXin Li struct T { constexpr T() : n() {} int n; }; 843*67e74705SXin Li static_assert(T().n == 0, ""); Udr178::U844*67e74705SXin Li struct U : S { constexpr U() : S() {} }; 845*67e74705SXin Li static_assert(U().b == 0, ""); 846*67e74705SXin Li #endif 847*67e74705SXin Li } 848*67e74705SXin Li 849*67e74705SXin Li namespace dr179 { // dr179: yes 850*67e74705SXin Li void f(); 851*67e74705SXin Li int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} 852*67e74705SXin Li } 853*67e74705SXin Li 854*67e74705SXin Li namespace dr180 { // dr180: yes 855*67e74705SXin Li template<typename T> struct X : T, T::some_base { Xdr180::X856*67e74705SXin Li X() : T::some_type_that_might_be_T(), T::some_base() {} 857*67e74705SXin Li friend class T::some_class; fdr180::X858*67e74705SXin Li void f() { 859*67e74705SXin Li enum T::some_enum e; 860*67e74705SXin Li } 861*67e74705SXin Li }; 862*67e74705SXin Li } 863*67e74705SXin Li 864*67e74705SXin Li namespace dr181 { // dr181: yes 865*67e74705SXin Li namespace X { 866*67e74705SXin Li template <template X<class T> > struct A { }; // expected-error +{{}} 867*67e74705SXin Li template <template X<class T> > void f(A<X>) { } // expected-error +{{}} 868*67e74705SXin Li } 869*67e74705SXin Li 870*67e74705SXin Li namespace Y { 871*67e74705SXin Li template <template <class T> class X> struct A { }; 872*67e74705SXin Li template <template <class T> class X> void f(A<X>) { } 873*67e74705SXin Li } 874*67e74705SXin Li } 875*67e74705SXin Li 876*67e74705SXin Li namespace dr182 { // dr182: yes 877*67e74705SXin Li template <class T> struct C { 878*67e74705SXin Li void f(); 879*67e74705SXin Li void g(); 880*67e74705SXin Li }; 881*67e74705SXin Li 882*67e74705SXin Li template <class T> void C<T>::f() {} 883*67e74705SXin Li template <class T> void C<T>::g() {} 884*67e74705SXin Li 885*67e74705SXin Li class A { 886*67e74705SXin Li class B {}; // expected-note {{here}} 887*67e74705SXin Li void f(); 888*67e74705SXin Li }; 889*67e74705SXin Li 890*67e74705SXin Li template void C<A::B>::f(); 891*67e74705SXin Li template <> void C<A::B>::g(); // expected-error {{private}} 892*67e74705SXin Li 893*67e74705SXin Li void A::f() { 894*67e74705SXin Li C<B> cb; 895*67e74705SXin Li cb.f(); 896*67e74705SXin Li } 897*67e74705SXin Li } 898*67e74705SXin Li 899*67e74705SXin Li namespace dr183 { // dr183: sup 382 900*67e74705SXin Li template<typename T> struct A {}; 901*67e74705SXin Li template<typename T> struct B { 902*67e74705SXin Li typedef int X; 903*67e74705SXin Li }; 904*67e74705SXin Li template<> struct A<int> { 905*67e74705SXin Li #if __cplusplus <= 199711 906*67e74705SXin Li typename B<int>::X x; // expected-error {{'typename' occurs outside of a template}} 907*67e74705SXin Li #else 908*67e74705SXin Li typename B<int>::X x; 909*67e74705SXin Li #endif 910*67e74705SXin Li }; 911*67e74705SXin Li } 912*67e74705SXin Li 913*67e74705SXin Li namespace dr184 { // dr184: yes 914*67e74705SXin Li template<typename T = float> struct B {}; 915*67e74705SXin Li 916*67e74705SXin Li template<template<typename TT = float> class T> struct A { 917*67e74705SXin Li void f(); 918*67e74705SXin Li void g(); 919*67e74705SXin Li }; 920*67e74705SXin Li 921*67e74705SXin Li template<template<typename TT> class T> void A<T>::f() { // expected-note {{here}} 922*67e74705SXin Li T<> t; // expected-error {{too few template arguments}} 923*67e74705SXin Li } 924*67e74705SXin Li 925*67e74705SXin Li template<template<typename TT = char> class T> void A<T>::g() { 926*67e74705SXin Li T<> t; 927*67e74705SXin Li typedef T<> X; 928*67e74705SXin Li typedef T<char> X; 929*67e74705SXin Li } 930*67e74705SXin Li 931*67e74705SXin Li void h() { A<B>().g(); } 932*67e74705SXin Li } 933*67e74705SXin Li 934*67e74705SXin Li // dr185 FIXME: add codegen test 935*67e74705SXin Li 936*67e74705SXin Li namespace dr187 { // dr187: sup 481 937*67e74705SXin Li const int Z = 1; 938*67e74705SXin Li template<int X = Z, int Z = X> struct A; 939*67e74705SXin Li typedef A<> T; 940*67e74705SXin Li typedef A<1, 1> T; 941*67e74705SXin Li } 942*67e74705SXin Li 943*67e74705SXin Li namespace dr188 { // dr188: yes 944*67e74705SXin Li char c[10]; 945*67e74705SXin Li int check[sizeof(0, c) == 10 ? 1 : -1]; 946*67e74705SXin Li } 947*67e74705SXin Li 948*67e74705SXin Li // dr190 FIXME: add codegen test for tbaa 949*67e74705SXin Li 950*67e74705SXin Li // dr193 FIXME: add codegen test 951*67e74705SXin Li 952*67e74705SXin Li namespace dr194 { // dr194: yes 953*67e74705SXin Li struct A { 954*67e74705SXin Li A(); 955*67e74705SXin Li void A(); // expected-error {{constructor cannot have a return type}} 956*67e74705SXin Li }; 957*67e74705SXin Li struct B { 958*67e74705SXin Li void B(); // expected-error {{constructor cannot have a return type}} 959*67e74705SXin Li B(); 960*67e74705SXin Li }; 961*67e74705SXin Li struct C { 962*67e74705SXin Li inline explicit C(int) {} 963*67e74705SXin Li }; 964*67e74705SXin Li } 965*67e74705SXin Li 966*67e74705SXin Li namespace dr195 { // dr195: yes 967*67e74705SXin Li void f(); 968*67e74705SXin Li int *p = (int*)&f; // expected-error 0-1{{extension}} 969*67e74705SXin Li void (*q)() = (void(*)())&p; // expected-error 0-1{{extension}} 970*67e74705SXin Li } 971*67e74705SXin Li 972*67e74705SXin Li namespace dr197 { // dr197: yes 973*67e74705SXin Li char &f(char); 974*67e74705SXin Li 975*67e74705SXin Li template <class T> void g(T t) { 976*67e74705SXin Li char &a = f(1); 977*67e74705SXin Li char &b = f(T(1)); // expected-error {{unrelated type 'int'}} 978*67e74705SXin Li char &c = f(t); // expected-error {{unrelated type 'int'}} 979*67e74705SXin Li } 980*67e74705SXin Li 981*67e74705SXin Li void f(int); 982*67e74705SXin Li 983*67e74705SXin Li enum E { e }; 984*67e74705SXin Li int &f(E); 985*67e74705SXin Li 986*67e74705SXin Li void h() { 987*67e74705SXin Li g('a'); 988*67e74705SXin Li g(2); 989*67e74705SXin Li g(e); // expected-note {{in instantiation of}} 990*67e74705SXin Li } 991*67e74705SXin Li } 992*67e74705SXin Li 993*67e74705SXin Li namespace dr198 { // dr198: yes 994*67e74705SXin Li struct A { 995*67e74705SXin Li int n; 996*67e74705SXin Li struct B { 997*67e74705SXin Li int m[sizeof(n)]; 998*67e74705SXin Li #if __cplusplus < 201103L 999*67e74705SXin Li // expected-error@-2 {{invalid use of non-static data member}} 1000*67e74705SXin Li #endif 1001*67e74705SXin Li int f() { return n; } 1002*67e74705SXin Li // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'B'}} 1003*67e74705SXin Li }; 1004*67e74705SXin Li struct C; 1005*67e74705SXin Li struct D; 1006*67e74705SXin Li }; 1007*67e74705SXin Li struct A::C { 1008*67e74705SXin Li int m[sizeof(n)]; 1009*67e74705SXin Li #if __cplusplus < 201103L 1010*67e74705SXin Li // expected-error@-2 {{invalid use of non-static data member}} 1011*67e74705SXin Li #endif 1012*67e74705SXin Li int f() { return n; } 1013*67e74705SXin Li // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'C'}} 1014*67e74705SXin Li }; 1015*67e74705SXin Li struct A::D : A { 1016*67e74705SXin Li int m[sizeof(n)]; 1017*67e74705SXin Li #if __cplusplus < 201103L 1018*67e74705SXin Li // expected-error@-2 {{invalid use of non-static data member}} 1019*67e74705SXin Li #endif 1020*67e74705SXin Li int f() { return n; } 1021*67e74705SXin Li }; 1022*67e74705SXin Li } 1023*67e74705SXin Li 1024*67e74705SXin Li // dr199 FIXME: add codegen test 1025