1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -verify %s 2*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++1z -Wc++11-compat -verify %s 3*67e74705SXin Li 4*67e74705SXin Li #if __cplusplus < 201103L 5*67e74705SXin Li 6*67e74705SXin Li namespace N { f(T)7*67e74705SXin Li template<typename T> void f(T) {} // expected-note 2{{here}} 8*67e74705SXin Li namespace M { 9*67e74705SXin Li template void ::N::f<int>(int); // expected-warning {{explicit instantiation of 'f' not in a namespace enclosing 'N'}} 10*67e74705SXin Li } 11*67e74705SXin Li } 12*67e74705SXin Li using namespace N; 13*67e74705SXin Li template void f<char>(char); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}} 14*67e74705SXin Li g(T)15*67e74705SXin Litemplate<typename T> void g(T) {} // expected-note 2{{here}} 16*67e74705SXin Li namespace M { 17*67e74705SXin Li template void g<int>(int); // expected-warning {{explicit instantiation of 'g' must occur at global scope}} 18*67e74705SXin Li template void ::g<char>(char); // expected-warning {{explicit instantiation of 'g' must occur at global scope}} 19*67e74705SXin Li } 20*67e74705SXin Li 21*67e74705SXin Li template inline void g<double>(double); // expected-warning {{explicit instantiation cannot be 'inline'}} 22*67e74705SXin Li g()23*67e74705SXin Livoid g() { 24*67e74705SXin Li auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}} 25*67e74705SXin Li } 26*67e74705SXin Li 27*67e74705SXin Li int n; 28*67e74705SXin Li struct S { 29*67e74705SXin Li char c; 30*67e74705SXin Li } 31*67e74705SXin Li s = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++11}} expected-note {{explicit cast}} 32*67e74705SXin Li t = { 1234 }; // expected-warning {{constant expression evaluates to 1234 which cannot be narrowed to type 'char' in C++11}} expected-warning {{changes value}} expected-note {{explicit cast}} 33*67e74705SXin Li 34*67e74705SXin Li #define PRIuS "uS" 35*67e74705SXin Li int printf(const char *, ...); 36*67e74705SXin Li typedef __typeof(sizeof(int)) size_t; h(size_t foo,size_t bar)37*67e74705SXin Livoid h(size_t foo, size_t bar) { 38*67e74705SXin Li printf("foo is %"PRIuS", bar is %"PRIuS, foo, bar); // expected-warning 2{{identifier after literal will be treated as a reserved user-defined literal suffix in C++11}} 39*67e74705SXin Li } 40*67e74705SXin Li 41*67e74705SXin Li #define _x + 1 42*67e74705SXin Li char c = 'x'_x; // expected-warning {{will be treated as a user-defined literal suffix}} 43*67e74705SXin Li f()44*67e74705SXin Litemplate<int ...N> int f() { // expected-warning {{C++11 extension}} 45*67e74705SXin Li return (N + ...); // expected-warning {{C++1z extension}} 46*67e74705SXin Li } 47*67e74705SXin Li 48*67e74705SXin Li #else 49*67e74705SXin Li __anon550d58ef0102null50*67e74705SXin Liauto init_capture = [a(0)] {}; // expected-warning {{initialized lambda captures are incompatible with C++ standards before C++14}} 51*67e74705SXin Li static_assert(true); // expected-warning {{incompatible with C++ standards before C++1z}} 52*67e74705SXin Li f()53*67e74705SXin Litemplate<int ...N> int f() { return (N + ...); } // expected-warning {{incompatible with C++ standards before C++1z}} 54*67e74705SXin Li 55*67e74705SXin Li #endif 56