blob: 123008aadd81754e38ed908edeb8747eba70e53a [file] [log] [blame]
David Blaikie5f31f082011-10-18 05:54:07 +00001// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -verify %s
Richard Smithe1677d92011-10-11 17:38:48 +00002
3namespace N {
Richard Smith3e2e91e2011-10-18 02:28:33 +00004 template<typename T> void f(T) {} // expected-note 2{{here}}
Richard Smithe1677d92011-10-11 17:38:48 +00005 namespace M {
Richard Smith3e2e91e2011-10-18 02:28:33 +00006 template void ::N::f<int>(int); // expected-warning {{explicit instantiation of 'f' not in a namespace enclosing 'N'}}
Richard Smithe1677d92011-10-11 17:38:48 +00007 }
8}
Richard Smith3e2e91e2011-10-18 02:28:33 +00009using namespace N;
10template void f<char>(char); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}}
Richard Smithe1677d92011-10-11 17:38:48 +000011
Richard Smith3e2e91e2011-10-18 02:28:33 +000012template<typename T> void g(T) {} // expected-note 2{{here}}
Richard Smithe1677d92011-10-11 17:38:48 +000013namespace M {
Richard Smith3e2e91e2011-10-18 02:28:33 +000014 template void g<int>(int); // expected-warning {{explicit instantiation of 'g' must occur at global scope}}
15 template void ::g<char>(char); // expected-warning {{explicit instantiation of 'g' must occur at global scope}}
Richard Smithe1677d92011-10-11 17:38:48 +000016}
17
Richard Smith2dc7ece2011-10-18 03:44:03 +000018template inline void g<double>(double); // expected-warning {{explicit instantiation cannot be 'inline'}}
19
Richard Smith3e2e91e2011-10-18 02:28:33 +000020void g() {
Douglas Gregorb3df1382011-10-12 19:26:40 +000021 auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}}
Richard Smithe1677d92011-10-11 17:38:48 +000022}
23
24int n;
25struct S {
26 char c;
27}
Douglas Gregorb3df1382011-10-12 19:26:40 +000028s = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++11}} expected-note {{explicit cast}}
29t = { 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}}
Richard Smithe816c712012-03-07 03:13:00 +000030
31#define PRIuS "uS"
32int printf(const char *, ...);
33typedef __typeof(sizeof(int)) size_t;
34void h(size_t foo, size_t bar) {
Richard Smith2fb4ae32012-03-08 02:39:21 +000035 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}}
Richard Smithe816c712012-03-07 03:13:00 +000036}
37
Richard Smith2fb4ae32012-03-08 02:39:21 +000038#define _x + 1
39char c = 'x'_x; // expected-warning {{will be treated as a user-defined literal suffix}}