cxx0x-compat.cpp revision b3df1386680b3830d2f4d300d4d7eaba134135fc
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() {
16b3df1386680b3830d2f4d300d4d7eaba134135fcDouglas Gregor  auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}}
17e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith}
18e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith
19e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithint n;
20e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smithstruct S {
21e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith  char c;
22e1677d97281d7e5059e15ed456e03cb02e475f08Richard Smith}
23b3df1386680b3830d2f4d300d4d7eaba134135fcDouglas 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}}
24b3df1386680b3830d2f4d300d4d7eaba134135fcDouglas 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}}
25