15f31f0893d75203c326ddcd9808099bbfe34aec0David Blaikie// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -verify %s 2e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith 3e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithnamespace N { 43e2e91e934ecf083a7c0835b58d9627ca2faddc9Richard Smith template<typename T> void f(T) {} // expected-note 2{{here}} 5e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith namespace M { 63e2e91e934ecf083a7c0835b58d9627ca2faddc9Richard Smith template void ::N::f<int>(int); // expected-warning {{explicit instantiation of 'f' not in a namespace enclosing 'N'}} 7e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith } 8e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith} 93e2e91e934ecf083a7c0835b58d9627ca2faddc9Richard Smithusing namespace N; 103e2e91e934ecf083a7c0835b58d9627ca2faddc9Richard Smithtemplate void f<char>(char); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}} 11e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith 123e2e91e934ecf083a7c0835b58d9627ca2faddc9Richard Smithtemplate<typename T> void g(T) {} // expected-note 2{{here}} 13e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithnamespace M { 143e2e91e934ecf083a7c0835b58d9627ca2faddc9Richard Smith template void g<int>(int); // expected-warning {{explicit instantiation of 'g' must occur at global scope}} 153e2e91e934ecf083a7c0835b58d9627ca2faddc9Richard Smith template void ::g<char>(char); // expected-warning {{explicit instantiation of 'g' must occur at global scope}} 16e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith} 17e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith 182dc7ece8a83f371cb86c2f93282cb3c8e2d010ecRichard Smithtemplate inline void g<double>(double); // expected-warning {{explicit instantiation cannot be 'inline'}} 192dc7ece8a83f371cb86c2f93282cb3c8e2d010ecRichard Smith 203e2e91e934ecf083a7c0835b58d9627ca2faddc9Richard Smithvoid g() { 21b3df1386680b3830d2f4d300d4d7eaba134135fcDouglas Gregor auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}} 22e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith} 23e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith 24e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithint n; 25e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithstruct S { 26e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith char c; 27e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith} 28b3df1386680b3830d2f4d300d4d7eaba134135fcDouglas Gregors = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++11}} expected-note {{explicit cast}} 29b3df1386680b3830d2f4d300d4d7eaba134135fcDouglas Gregort = { 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}} 30e816c717d4de1de6c67f1fd5ef4a927fe2bf2ea7Richard Smith 31e816c717d4de1de6c67f1fd5ef4a927fe2bf2ea7Richard Smith#define PRIuS "uS" 32e816c717d4de1de6c67f1fd5ef4a927fe2bf2ea7Richard Smithint printf(const char *, ...); 33e816c717d4de1de6c67f1fd5ef4a927fe2bf2ea7Richard Smithtypedef __typeof(sizeof(int)) size_t; 34e816c717d4de1de6c67f1fd5ef4a927fe2bf2ea7Richard Smithvoid h(size_t foo, size_t bar) { 352fb4ae36825ca3a0cbe7e845c5747062870066beRichard Smith 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}} 36e816c717d4de1de6c67f1fd5ef4a927fe2bf2ea7Richard Smith} 37e816c717d4de1de6c67f1fd5ef4a927fe2bf2ea7Richard Smith 382fb4ae36825ca3a0cbe7e845c5747062870066beRichard Smith#define _x + 1 392fb4ae36825ca3a0cbe7e845c5747062870066beRichard Smithchar c = 'x'_x; // expected-warning {{will be treated as a user-defined literal suffix}} 40