David Blaikie | 5f31f08 | 2011-10-18 05:54:07 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -verify %s |
Richard Smith | e1677d9 | 2011-10-11 17:38:48 +0000 | [diff] [blame] | 2 | |
| 3 | namespace N { |
Richard Smith | 3e2e91e | 2011-10-18 02:28:33 +0000 | [diff] [blame] | 4 | template<typename T> void f(T) {} // expected-note 2{{here}} |
Richard Smith | e1677d9 | 2011-10-11 17:38:48 +0000 | [diff] [blame] | 5 | namespace M { |
Richard Smith | 3e2e91e | 2011-10-18 02:28:33 +0000 | [diff] [blame] | 6 | template void ::N::f<int>(int); // expected-warning {{explicit instantiation of 'f' not in a namespace enclosing 'N'}} |
Richard Smith | e1677d9 | 2011-10-11 17:38:48 +0000 | [diff] [blame] | 7 | } |
| 8 | } |
Richard Smith | 3e2e91e | 2011-10-18 02:28:33 +0000 | [diff] [blame] | 9 | using namespace N; |
| 10 | template void f<char>(char); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}} |
Richard Smith | e1677d9 | 2011-10-11 17:38:48 +0000 | [diff] [blame] | 11 | |
Richard Smith | 3e2e91e | 2011-10-18 02:28:33 +0000 | [diff] [blame] | 12 | template<typename T> void g(T) {} // expected-note 2{{here}} |
Richard Smith | e1677d9 | 2011-10-11 17:38:48 +0000 | [diff] [blame] | 13 | namespace M { |
Richard Smith | 3e2e91e | 2011-10-18 02:28:33 +0000 | [diff] [blame] | 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}} |
Richard Smith | e1677d9 | 2011-10-11 17:38:48 +0000 | [diff] [blame] | 16 | } |
| 17 | |
Richard Smith | 2dc7ece | 2011-10-18 03:44:03 +0000 | [diff] [blame] | 18 | template inline void g<double>(double); // expected-warning {{explicit instantiation cannot be 'inline'}} |
| 19 | |
Richard Smith | 3e2e91e | 2011-10-18 02:28:33 +0000 | [diff] [blame] | 20 | void g() { |
Douglas Gregor | b3df138 | 2011-10-12 19:26:40 +0000 | [diff] [blame] | 21 | auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}} |
Richard Smith | e1677d9 | 2011-10-11 17:38:48 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | int n; |
| 25 | struct S { |
| 26 | char c; |
| 27 | } |
Douglas Gregor | b3df138 | 2011-10-12 19:26:40 +0000 | [diff] [blame] | 28 | s = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++11}} expected-note {{explicit cast}} |
| 29 | t = { 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}} |