cxx0x-compat.cpp revision 5f31f0893d75203c326ddcd9808099bbfe34aec0
1// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -verify %s 2 3namespace N { 4 template<typename T> void f(T) {} // expected-note 2{{here}} 5 namespace M { 6 template void ::N::f<int>(int); // expected-warning {{explicit instantiation of 'f' not in a namespace enclosing 'N'}} 7 } 8} 9using namespace N; 10template void f<char>(char); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}} 11 12template<typename T> void g(T) {} // expected-note 2{{here}} 13namespace M { 14 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}} 16} 17 18template inline void g<double>(double); // expected-warning {{explicit instantiation cannot be 'inline'}} 19 20void g() { 21 auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}} 22} 23 24int n; 25struct S { 26 char c; 27} 28s = { 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}} 30