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 std { struct type_info {}; } 7*0a6a1f1dSLionel Sambuc 8*0a6a1f1dSLionel Sambuc namespace dr601 { // dr601: yes 9*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L 10*0a6a1f1dSLionel Sambuc #define MAX __LLONG_MAX__ 11*0a6a1f1dSLionel Sambuc #else 12*0a6a1f1dSLionel Sambuc #define MAX __LONG_MAX__ 13*0a6a1f1dSLionel Sambuc #endif 14*0a6a1f1dSLionel Sambuc 15*0a6a1f1dSLionel Sambuc #if 0x8000 < -1 16*0a6a1f1dSLionel Sambuc #error 0x8000 should be signed 17*0a6a1f1dSLionel Sambuc #endif 18*0a6a1f1dSLionel Sambuc 19*0a6a1f1dSLionel Sambuc #if MAX > 0xFFFFFFFF && 0x80000000 < -1 20*0a6a1f1dSLionel Sambuc #error 0x80000000 should be signed 21*0a6a1f1dSLionel Sambuc #endif 22*0a6a1f1dSLionel Sambuc 23*0a6a1f1dSLionel Sambuc #if __INT_MAX__ == 0x7FFFFFFF 24*0a6a1f1dSLionel Sambuc _Static_assert(0x80000000 < -1, "0x80000000 should be unsigned"); // expected-error {{C11}} 25*0a6a1f1dSLionel Sambuc #endif 26*0a6a1f1dSLionel Sambuc 27*0a6a1f1dSLionel Sambuc #if MAX > 0xFFFFFFFFFFFFFFFF && 0x8000000000000000 < -1 28*0a6a1f1dSLionel Sambuc #error 0x8000000000000000 should be signed 29*0a6a1f1dSLionel Sambuc #endif 30*0a6a1f1dSLionel Sambuc 31*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFFFFFFFFFFFFFF 32*0a6a1f1dSLionel Sambuc static_assert(0x8000000000000000 < -1, "0x8000000000000000 should be unsigned"); // expected-error {{C11}} 33*0a6a1f1dSLionel Sambuc #endif 34*0a6a1f1dSLionel Sambuc 35*0a6a1f1dSLionel Sambuc #undef MAX 36*0a6a1f1dSLionel Sambuc } 37*0a6a1f1dSLionel Sambuc 38*0a6a1f1dSLionel Sambuc namespace dr602 { // dr602: yes 39*0a6a1f1dSLionel Sambuc template<class T> struct A { 40*0a6a1f1dSLionel Sambuc template<class U> friend struct A; 41*0a6a1f1dSLionel Sambuc }; 42*0a6a1f1dSLionel Sambuc 43*0a6a1f1dSLionel Sambuc template<class T> struct B { 44*0a6a1f1dSLionel Sambuc class C { 45*0a6a1f1dSLionel Sambuc template<class U> friend struct B; 46*0a6a1f1dSLionel Sambuc typedef int type; 47*0a6a1f1dSLionel Sambuc }; 48*0a6a1f1dSLionel Sambuc typename C::type ct; // ok, befriended 49*0a6a1f1dSLionel Sambuc }; 50*0a6a1f1dSLionel Sambuc B<int> b; 51*0a6a1f1dSLionel Sambuc } 52*0a6a1f1dSLionel Sambuc 53*0a6a1f1dSLionel Sambuc namespace dr603 { // dr603: yes 54*0a6a1f1dSLionel Sambuc template<unsigned char> struct S {}; 55*0a6a1f1dSLionel Sambuc typedef S<'\001'> S1; 56*0a6a1f1dSLionel Sambuc typedef S<(1ul << __CHAR_BIT__) + 1> S1; 57*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L 58*0a6a1f1dSLionel Sambuc // expected-error@-2 {{cannot be narrowed}} 59*0a6a1f1dSLionel Sambuc #endif 60*0a6a1f1dSLionel Sambuc } 61*0a6a1f1dSLionel Sambuc 62*0a6a1f1dSLionel Sambuc // dr604: na 63*0a6a1f1dSLionel Sambuc // dr605 needs IRGen test 64*0a6a1f1dSLionel Sambuc 65*0a6a1f1dSLionel Sambuc namespace dr606 { // dr606: yes 66*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L 67*0a6a1f1dSLionel Sambuc template<typename T> struct S {}; 68*0a6a1f1dSLionel Sambuc template<typename T> void f(S<T> &&); // expected-note {{no known conversion from 'S<int>' to 'S<int> &&'}} 69*0a6a1f1dSLionel Sambuc template<typename T> void g(T &&); 70*0a6a1f1dSLionel Sambuc template<typename T> void h(const T &&); // expected-note {{no known conversion from 'S<int>' to 'const dr606::S<int> &&'}} 71*0a6a1f1dSLionel Sambuc test(S<int> s)72*0a6a1f1dSLionel Sambuc void test(S<int> s) { 73*0a6a1f1dSLionel Sambuc f(s); // expected-error {{no match}} 74*0a6a1f1dSLionel Sambuc g(s); 75*0a6a1f1dSLionel Sambuc h(s); // expected-error {{no match}} 76*0a6a1f1dSLionel Sambuc 77*0a6a1f1dSLionel Sambuc g(test); 78*0a6a1f1dSLionel Sambuc h(test); // ok, an rvalue reference can bind to a function lvalue 79*0a6a1f1dSLionel Sambuc } 80*0a6a1f1dSLionel Sambuc #endif 81*0a6a1f1dSLionel Sambuc } 82*0a6a1f1dSLionel Sambuc 83*0a6a1f1dSLionel Sambuc namespace dr608 { // dr608: yes 84*0a6a1f1dSLionel Sambuc struct A { virtual void f(); }; 85*0a6a1f1dSLionel Sambuc struct B : A {}; 86*0a6a1f1dSLionel Sambuc struct C : A { void f(); }; 87*0a6a1f1dSLionel Sambuc struct D : B, C {}; 88*0a6a1f1dSLionel Sambuc } 89*0a6a1f1dSLionel Sambuc 90*0a6a1f1dSLionel Sambuc int dr610[-0u == 0u ? 1 : -1]; // dr610: yes 91*0a6a1f1dSLionel Sambuc 92*0a6a1f1dSLionel Sambuc namespace dr611 { // dr611: yes 93*0a6a1f1dSLionel Sambuc int k; 94*0a6a1f1dSLionel Sambuc struct S { int &r; } s = { k ? k : k }; 95*0a6a1f1dSLionel Sambuc } 96*0a6a1f1dSLionel Sambuc 97*0a6a1f1dSLionel Sambuc // dr612: na 98*0a6a1f1dSLionel Sambuc 99*0a6a1f1dSLionel Sambuc namespace dr613 { // dr613: yes c++11 100*0a6a1f1dSLionel Sambuc // see also n2253 101*0a6a1f1dSLionel Sambuc struct A { int n; static void f(); }; 102*0a6a1f1dSLionel Sambuc int f(int); 103*0a6a1f1dSLionel Sambuc struct B { virtual void f(); }; 104*0a6a1f1dSLionel Sambuc B &g(int); 105*0a6a1f1dSLionel Sambuc 106*0a6a1f1dSLionel Sambuc int an1 = sizeof(A::n); 107*0a6a1f1dSLionel Sambuc int an2 = sizeof(A::n + 1); // valid per dr850 108*0a6a1f1dSLionel Sambuc int an3 = sizeof A::n; 109*0a6a1f1dSLionel Sambuc int an4 = sizeof(f(A::n)); 110*0a6a1f1dSLionel Sambuc int an5 = sizeof(g(A::n)); 111*0a6a1f1dSLionel Sambuc const std::type_info &an6 = typeid(A::n); 112*0a6a1f1dSLionel Sambuc const std::type_info &an7 = typeid(A::n + 1); 113*0a6a1f1dSLionel Sambuc const std::type_info &an8 = typeid(f(A::n)); 114*0a6a1f1dSLionel Sambuc const std::type_info &an9 = typeid(g(A::n)); // expected-error {{non-static}} 115*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 116*0a6a1f1dSLionel Sambuc // expected-error@-10 {{non-static}} 117*0a6a1f1dSLionel Sambuc // expected-error@-10 {{non-static}} 118*0a6a1f1dSLionel Sambuc // expected-error@-10 {{non-static}} 119*0a6a1f1dSLionel Sambuc // expected-error@-10 {{non-static}} 120*0a6a1f1dSLionel Sambuc // expected-error@-10 {{non-static}} 121*0a6a1f1dSLionel Sambuc // expected-error@-10 {{non-static}} 122*0a6a1f1dSLionel Sambuc // expected-error@-10 {{non-static}} 123*0a6a1f1dSLionel Sambuc // expected-error@-10 {{non-static}} 124*0a6a1f1dSLionel Sambuc #endif 125*0a6a1f1dSLionel Sambuc f()126*0a6a1f1dSLionel Sambuc void A::f() { 127*0a6a1f1dSLionel Sambuc int an1 = sizeof n; 128*0a6a1f1dSLionel Sambuc const std::type_info &an2 = typeid(n + 1); 129*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 130*0a6a1f1dSLionel Sambuc // expected-error@-3 {{static}} 131*0a6a1f1dSLionel Sambuc // expected-error@-3 {{static}} 132*0a6a1f1dSLionel Sambuc #endif 133*0a6a1f1dSLionel Sambuc const std::type_info &an3 = typeid(g(n)); // expected-error {{static}} 134*0a6a1f1dSLionel Sambuc } 135*0a6a1f1dSLionel Sambuc } 136*0a6a1f1dSLionel Sambuc 137*0a6a1f1dSLionel Sambuc int dr614_a[(-1) / 2 == 0 ? 1 : -1]; // dr614: yes 138*0a6a1f1dSLionel Sambuc int dr614_b[(-1) % 2 == -1 ? 1 : -1]; 139*0a6a1f1dSLionel Sambuc 140*0a6a1f1dSLionel Sambuc namespace dr615 { // dr615: yes 141*0a6a1f1dSLionel Sambuc int f(); 142*0a6a1f1dSLionel Sambuc static int n = f(); 143*0a6a1f1dSLionel Sambuc } 144*0a6a1f1dSLionel Sambuc 145*0a6a1f1dSLionel Sambuc namespace dr616 { // dr616: no 146*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L 147*0a6a1f1dSLionel Sambuc struct S { int n; } s; 148*0a6a1f1dSLionel Sambuc // FIXME: These should all be 'int &&' 149*0a6a1f1dSLionel Sambuc using T = decltype(S().n); // expected-note 2{{previous}} 150*0a6a1f1dSLionel Sambuc using T = decltype(static_cast<S&&>(s).n); 151*0a6a1f1dSLionel Sambuc using T = decltype(S().*&S::n); 152*0a6a1f1dSLionel Sambuc using T = decltype(static_cast<S&&>(s).*&S::n); // expected-error {{different type}} 153*0a6a1f1dSLionel Sambuc using T = int&&; // expected-error {{different type}} 154*0a6a1f1dSLionel Sambuc #endif 155*0a6a1f1dSLionel Sambuc } 156*0a6a1f1dSLionel Sambuc 157*0a6a1f1dSLionel Sambuc namespace dr618 { // dr618: yes 158*0a6a1f1dSLionel Sambuc #if (unsigned)-1 > 0 159*0a6a1f1dSLionel Sambuc #error wrong 160*0a6a1f1dSLionel Sambuc #endif 161*0a6a1f1dSLionel Sambuc } 162*0a6a1f1dSLionel Sambuc 163*0a6a1f1dSLionel Sambuc namespace dr619 { // dr619: yes 164*0a6a1f1dSLionel Sambuc extern int x[10]; 165*0a6a1f1dSLionel Sambuc struct S { static int x[10]; }; 166*0a6a1f1dSLionel Sambuc 167*0a6a1f1dSLionel Sambuc int x[]; 168*0a6a1f1dSLionel Sambuc _Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}} 169*0a6a1f1dSLionel Sambuc extern int x[]; 170*0a6a1f1dSLionel Sambuc _Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}} 171*0a6a1f1dSLionel Sambuc 172*0a6a1f1dSLionel Sambuc int S::x[]; 173*0a6a1f1dSLionel Sambuc _Static_assert(sizeof(S::x) == sizeof(int) * 10, ""); // expected-error {{C11}} 174*0a6a1f1dSLionel Sambuc f()175*0a6a1f1dSLionel Sambuc void f() { 176*0a6a1f1dSLionel Sambuc extern int x[]; 177*0a6a1f1dSLionel Sambuc sizeof(x); // expected-error {{incomplete}} 178*0a6a1f1dSLionel Sambuc } 179*0a6a1f1dSLionel Sambuc } 180*0a6a1f1dSLionel Sambuc 181*0a6a1f1dSLionel Sambuc // dr620: dup 568 182*0a6a1f1dSLionel Sambuc 183*0a6a1f1dSLionel Sambuc namespace dr621 { 184*0a6a1f1dSLionel Sambuc template<typename T> T f(); f()185*0a6a1f1dSLionel Sambuc template<> int f() {} // expected-note {{previous}} f()186*0a6a1f1dSLionel Sambuc template<> int f<int>() {} // expected-error {{redefinition}} 187*0a6a1f1dSLionel Sambuc } 188*0a6a1f1dSLionel Sambuc 189*0a6a1f1dSLionel Sambuc // dr623: na 190*0a6a1f1dSLionel Sambuc // FIXME: Add documentation saying we allow invalid pointer values. 191*0a6a1f1dSLionel Sambuc 192*0a6a1f1dSLionel Sambuc // dr624 needs an IRGen check. 193*0a6a1f1dSLionel Sambuc 194*0a6a1f1dSLionel Sambuc namespace dr625 { // dr625: yes 195*0a6a1f1dSLionel Sambuc template<typename T> struct A {}; 196*0a6a1f1dSLionel Sambuc A<auto> x = A<int>(); // expected-error {{'auto' not allowed in template argument}} expected-error 0-1{{extension}} 197*0a6a1f1dSLionel Sambuc void f(int); 198*0a6a1f1dSLionel Sambuc void (*p)(auto) = f; // expected-error {{'auto' not allowed in function prototype}} expected-error 0-1{{extension}} 199*0a6a1f1dSLionel Sambuc } 200*0a6a1f1dSLionel Sambuc 201*0a6a1f1dSLionel Sambuc namespace dr626 { // dr626: yes 202*0a6a1f1dSLionel Sambuc #define STR(x) #x 203*0a6a1f1dSLionel Sambuc char c[2] = STR(c); // ok, type matches 204*0a6a1f1dSLionel Sambuc wchar_t w[2] = STR(w); // expected-error {{initializing wide char array with non-wide string literal}} 205*0a6a1f1dSLionel Sambuc } 206*0a6a1f1dSLionel Sambuc 207*0a6a1f1dSLionel Sambuc namespace dr627 { // dr627: yes f()208*0a6a1f1dSLionel Sambuc void f() { 209*0a6a1f1dSLionel Sambuc true a = 0; // expected-error +{{}} expected-warning {{unused}} 210*0a6a1f1dSLionel Sambuc } 211*0a6a1f1dSLionel Sambuc } 212*0a6a1f1dSLionel Sambuc 213*0a6a1f1dSLionel Sambuc // dr628: na 214*0a6a1f1dSLionel Sambuc 215*0a6a1f1dSLionel Sambuc namespace dr629 { // dr629: yes 216*0a6a1f1dSLionel Sambuc typedef int T; 217*0a6a1f1dSLionel Sambuc int n = 1; f()218*0a6a1f1dSLionel Sambuc void f() { 219*0a6a1f1dSLionel Sambuc auto T = 2; 220*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L 221*0a6a1f1dSLionel Sambuc // expected-error@-2 {{expected unqualified-id}} 222*0a6a1f1dSLionel Sambuc #else 223*0a6a1f1dSLionel Sambuc // expected-note@-4 {{previous}} 224*0a6a1f1dSLionel Sambuc #endif 225*0a6a1f1dSLionel Sambuc 226*0a6a1f1dSLionel Sambuc auto T(n); 227*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L 228*0a6a1f1dSLionel Sambuc // expected-error@-2 {{redefinition of 'T'}} 229*0a6a1f1dSLionel Sambuc #endif 230*0a6a1f1dSLionel Sambuc } 231*0a6a1f1dSLionel Sambuc } 232*0a6a1f1dSLionel Sambuc 233*0a6a1f1dSLionel Sambuc namespace dr630 { // dr630: yes 234*0a6a1f1dSLionel Sambuc const bool MB_EQ_WC = 235*0a6a1f1dSLionel Sambuc ' ' == L' ' && '\t' == L'\t' && '\v' == L'\v' && '\r' == L'\r' && 236*0a6a1f1dSLionel Sambuc '\n' == L'\n' && // 237*0a6a1f1dSLionel Sambuc 'a' == L'a' && 'b' == L'b' && 'c' == L'c' && 'd' == L'd' && 'e' == L'e' && 238*0a6a1f1dSLionel Sambuc 'f' == L'f' && 'g' == L'g' && 'h' == L'h' && 'i' == L'i' && 'j' == L'j' && 239*0a6a1f1dSLionel Sambuc 'k' == L'k' && 'l' == L'l' && 'm' == L'm' && 'n' == L'n' && 'o' == L'o' && 240*0a6a1f1dSLionel Sambuc 'p' == L'p' && 'q' == L'q' && 'r' == L'r' && 's' == L's' && 't' == L't' && 241*0a6a1f1dSLionel Sambuc 'u' == L'u' && 'v' == L'v' && 'w' == L'w' && 'x' == L'x' && 'y' == L'y' && 242*0a6a1f1dSLionel Sambuc 'z' == L'z' && // 243*0a6a1f1dSLionel Sambuc 'A' == L'A' && 'B' == L'B' && 'C' == L'C' && 'D' == L'D' && 'E' == L'E' && 244*0a6a1f1dSLionel Sambuc 'F' == L'F' && 'G' == L'G' && 'H' == L'H' && 'I' == L'I' && 'J' == L'J' && 245*0a6a1f1dSLionel Sambuc 'K' == L'K' && 'L' == L'L' && 'M' == L'M' && 'N' == L'N' && 'O' == L'O' && 246*0a6a1f1dSLionel Sambuc 'P' == L'P' && 'Q' == L'Q' && 'R' == L'R' && 'S' == L'S' && 'T' == L'T' && 247*0a6a1f1dSLionel Sambuc 'U' == L'U' && 'V' == L'V' && 'W' == L'W' && 'X' == L'X' && 'Y' == L'Y' && 248*0a6a1f1dSLionel Sambuc 'Z' == L'Z' && // 249*0a6a1f1dSLionel Sambuc '0' == L'0' && '1' == L'1' && '2' == L'2' && '3' == L'3' && '4' == L'4' && 250*0a6a1f1dSLionel Sambuc '5' == L'5' && '6' == L'6' && '7' == L'7' && '8' == L'8' && 251*0a6a1f1dSLionel Sambuc '9' == L'9' && // 252*0a6a1f1dSLionel Sambuc '_' == L'_' && '{' == L'{' && '}' == L'}' && '[' == L'[' && ']' == L']' && 253*0a6a1f1dSLionel Sambuc '#' == L'#' && '(' == L'(' && ')' == L')' && '<' == L'<' && '>' == L'>' && 254*0a6a1f1dSLionel Sambuc '%' == L'%' && ':' == L':' && ';' == L';' && '.' == L'.' && '?' == L'?' && 255*0a6a1f1dSLionel Sambuc '*' == L'*' && '+' == L'+' && '-' == L'-' && '/' == L'/' && '^' == L'^' && 256*0a6a1f1dSLionel Sambuc '&' == L'&' && '|' == L'|' && '~' == L'~' && '!' == L'!' && '=' == L'=' && 257*0a6a1f1dSLionel Sambuc ',' == L',' && '\\' == L'\\' && '"' == L'"' && '\'' == L'\''; 258*0a6a1f1dSLionel Sambuc #if __STDC_MB_MIGHT_NEQ_WC__ 259*0a6a1f1dSLionel Sambuc #ifndef __FreeBSD__ // PR22208, FreeBSD expects us to give a bad (but conforming) answer here. 260*0a6a1f1dSLionel Sambuc _Static_assert(!MB_EQ_WC, "__STDC_MB_MIGHT_NEQ_WC__ but all basic source characters have same representation"); // expected-error {{C11}} 261*0a6a1f1dSLionel Sambuc #endif 262*0a6a1f1dSLionel Sambuc #else 263*0a6a1f1dSLionel Sambuc _Static_assert(MB_EQ_WC, "!__STDC_MB_MIGHT_NEQ_WC__ but some character differs"); // expected-error {{C11}} 264*0a6a1f1dSLionel Sambuc #endif 265*0a6a1f1dSLionel Sambuc } 266*0a6a1f1dSLionel Sambuc 267*0a6a1f1dSLionel Sambuc // dr631: na 268*0a6a1f1dSLionel Sambuc 269*0a6a1f1dSLionel Sambuc namespace dr632 { // dr632: yes 270*0a6a1f1dSLionel Sambuc struct S { int n; } s = {{5}}; // expected-warning {{braces}} 271*0a6a1f1dSLionel Sambuc } 272*0a6a1f1dSLionel Sambuc 273*0a6a1f1dSLionel Sambuc // dr633: na 274*0a6a1f1dSLionel Sambuc // see also n2993 275*0a6a1f1dSLionel Sambuc 276*0a6a1f1dSLionel Sambuc namespace dr634 { // dr634: yes 277*0a6a1f1dSLionel Sambuc struct S { S(); S(const S&); virtual void f(); ~S(); }; 278*0a6a1f1dSLionel Sambuc int f(...); 279*0a6a1f1dSLionel Sambuc char f(int); 280*0a6a1f1dSLionel Sambuc template<typename T> int (&g(T))[sizeof f(T())]; 281*0a6a1f1dSLionel Sambuc int (&a)[sizeof(int)] = g(S()); 282*0a6a1f1dSLionel Sambuc int (&b)[1] = g(0); 283*0a6a1f1dSLionel Sambuc int k = f(S()); // expected-error {{cannot pass}} 284*0a6a1f1dSLionel Sambuc } 285*0a6a1f1dSLionel Sambuc 286*0a6a1f1dSLionel Sambuc namespace dr635 { // dr635: yes 287*0a6a1f1dSLionel Sambuc template<typename T> struct A { A(); ~A(); }; A()288*0a6a1f1dSLionel Sambuc template<typename T> A<T>::A<T>() {} // expected-error {{cannot have template arguments}} ~A()289*0a6a1f1dSLionel Sambuc template<typename T> A<T>::~A<T>() {} 290*0a6a1f1dSLionel Sambuc 291*0a6a1f1dSLionel Sambuc template<typename T> struct B { B(); ~B(); }; B()292*0a6a1f1dSLionel Sambuc template<typename T> B<T>::B() {} ~B()293*0a6a1f1dSLionel Sambuc template<typename T> B<T>::~B() {} 294*0a6a1f1dSLionel Sambuc 295*0a6a1f1dSLionel Sambuc struct C { template<typename T> C(); C(); }; C()296*0a6a1f1dSLionel Sambuc template<typename T> C::C() {} C()297*0a6a1f1dSLionel Sambuc C::C() {} C()298*0a6a1f1dSLionel Sambuc template<> C::C<int>() {} // expected-error {{constructor name}} expected-error {{unqualified-id}} 299*0a6a1f1dSLionel Sambuc /*FIXME: needed for error recovery:*/; 300*0a6a1f1dSLionel Sambuc 301*0a6a1f1dSLionel Sambuc template<typename T> struct D { template<typename U> D(); D(); }; D()302*0a6a1f1dSLionel Sambuc template<typename T> D<T>::D() {} // expected-note {{previous}} D()303*0a6a1f1dSLionel Sambuc template<typename T> template<typename U> D<T>::D() {} D()304*0a6a1f1dSLionel Sambuc template<typename T> D<T>::D<T>() {} // expected-error {{redefinition}} expected-error {{cannot have template arg}} 305*0a6a1f1dSLionel Sambuc } 306*0a6a1f1dSLionel Sambuc 307*0a6a1f1dSLionel Sambuc namespace dr637 { // dr637: yes f(int i)308*0a6a1f1dSLionel Sambuc void f(int i) { 309*0a6a1f1dSLionel Sambuc i = ++i + 1; 310*0a6a1f1dSLionel Sambuc i = i++ + 1; // expected-warning {{unsequenced}} 311*0a6a1f1dSLionel Sambuc } 312*0a6a1f1dSLionel Sambuc } 313*0a6a1f1dSLionel Sambuc 314*0a6a1f1dSLionel Sambuc namespace dr638 { // dr638: no 315*0a6a1f1dSLionel Sambuc template<typename T> struct A { 316*0a6a1f1dSLionel Sambuc struct B; 317*0a6a1f1dSLionel Sambuc void f(); 318*0a6a1f1dSLionel Sambuc void g(); 319*0a6a1f1dSLionel Sambuc struct C { 320*0a6a1f1dSLionel Sambuc void h(); 321*0a6a1f1dSLionel Sambuc }; 322*0a6a1f1dSLionel Sambuc }; 323*0a6a1f1dSLionel Sambuc 324*0a6a1f1dSLionel Sambuc class X { 325*0a6a1f1dSLionel Sambuc typedef int type; 326*0a6a1f1dSLionel Sambuc template<class T> friend struct A<T>::B; // expected-warning {{not supported}} 327*0a6a1f1dSLionel Sambuc template<class T> friend void A<T>::f(); // expected-warning {{not supported}} 328*0a6a1f1dSLionel Sambuc template<class T> friend void A<T>::g(); // expected-warning {{not supported}} 329*0a6a1f1dSLionel Sambuc template<class T> friend void A<T>::C::h(); // expected-warning {{not supported}} 330*0a6a1f1dSLionel Sambuc }; 331*0a6a1f1dSLionel Sambuc 332*0a6a1f1dSLionel Sambuc template<> struct A<int> { 333*0a6a1f1dSLionel Sambuc X::type a; // FIXME: private 334*0a6a1f1dSLionel Sambuc struct B { 335*0a6a1f1dSLionel Sambuc X::type b; // ok 336*0a6a1f1dSLionel Sambuc }; fdr638::A337*0a6a1f1dSLionel Sambuc int f() { X::type c; } // FIXME: private gdr638::A338*0a6a1f1dSLionel Sambuc void g() { X::type d; } // ok 339*0a6a1f1dSLionel Sambuc struct D { hdr638::A::D340*0a6a1f1dSLionel Sambuc void h() { X::type e; } // FIXME: private 341*0a6a1f1dSLionel Sambuc }; 342*0a6a1f1dSLionel Sambuc }; 343*0a6a1f1dSLionel Sambuc } 344*0a6a1f1dSLionel Sambuc 345*0a6a1f1dSLionel Sambuc namespace dr639 { // dr639: yes f(int i)346*0a6a1f1dSLionel Sambuc void f(int i) { 347*0a6a1f1dSLionel Sambuc void((i = 0) + (i = 0)); // expected-warning {{unsequenced}} 348*0a6a1f1dSLionel Sambuc } 349*0a6a1f1dSLionel Sambuc } 350