From: Richard Smith Date: Tue, 11 Oct 2011 17:38:48 +0000 (+0000) Subject: Add more testing for -Wc++0x-compat warnings. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1677d97281d7e5059e15ed456e03cb02e475f08;p=clang Add more testing for -Wc++0x-compat warnings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141685 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/SemaCXX/cxx0x-compat.cpp b/test/SemaCXX/cxx0x-compat.cpp new file mode 100644 index 0000000000..1c4cbb2134 --- /dev/null +++ b/test/SemaCXX/cxx0x-compat.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++0x-compat -verify %s + +namespace N { + template void f(T) {} // expected-note {{here}} + namespace M { + template void f(int); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}} + } +} + +template void f(T) {} // expected-note {{here}} +namespace M { + template void f(int); // expected-warning {{explicit instantiation of 'f' must occur in the global namespace}} +} + +void f() { + auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++0x}} +} + +int n; +struct S { + char c; +} +s = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++0x}} expected-note {{explicit cast}} +t = { 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}}