cxx0x-compat.cpp revision e1677d97281d7e5059e15ed456e03cb02e475f08
1e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++0x-compat -verify %s 2e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith 3e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithnamespace N { 4e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith template<typename T> void f(T) {} // expected-note {{here}} 5e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith namespace M { 6e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith template void f<int>(int); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}} 7e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith } 8e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith} 9e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith 10e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithtemplate<typename T> void f(T) {} // expected-note {{here}} 11e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithnamespace M { 12e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith template void f<int>(int); // expected-warning {{explicit instantiation of 'f' must occur in the global namespace}} 13e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith} 14e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith 15e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithvoid f() { 16e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++0x}} 17e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith} 18e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith 19e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithint n; 20e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithstruct S { 21e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith char c; 22e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith} 23e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smiths = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++0x}} expected-note {{explicit cast}} 24e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smitht = { 1234 }; // expected-warning {{constant expression evaluates to 1234 which cannot be narrowed to type 'char' in C++0x}} expected-warning {{changes value}} expected-note {{explicit cast}} 25