diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp index c20728332704..bb6bb73ec702 100644 --- a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp +++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify %s +// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify -std=c++11 %s // C++98 [basic.lookup.classref]p1: // In a class member access expression (5.2.5), if the . or -> token is @@ -21,10 +23,16 @@ // From PR 7247 template -struct set{}; // expected-note{{lookup from the current scope refers here}} +struct set{}; +#if __cplusplus <= 199711L +// expected-note@-2 {{lookup from the current scope refers here}} +#endif struct Value { template - void set(T value) {} // expected-note{{lookup in the object type 'Value' refers here}} + void set(T value) {} +#if __cplusplus <= 199711L + // expected-note@-2 {{lookup in the object type 'Value' refers here}} +#endif void resolves_to_same() { Value v; @@ -36,7 +44,10 @@ void resolves_to_different() { Value v; // The fact that the next line is a warning rather than an error is an // extension. - v.set(3.2); // expected-warning{{lookup of 'set' in member access expression is ambiguous; using member of 'Value'}} + v.set(3.2); +#if __cplusplus <= 199711L + // expected-warning@-2 {{lookup of 'set' in member access expression is ambiguous; using member of 'Value'}} +#endif } { int set; // Non-template. diff --git a/clang/test/CXX/class/class.friend/p1.cpp b/clang/test/CXX/class/class.friend/p1.cpp index b83dfa36cd35..037fc3dadb96 100644 --- a/clang/test/CXX/class/class.friend/p1.cpp +++ b/clang/test/CXX/class/class.friend/p1.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s struct Outer { struct Inner { @@ -41,7 +43,10 @@ class A { UndeclaredSoFar x; // expected-error {{unknown type name 'UndeclaredSoFar'}} void a_member(); - friend void A::a_member(); // expected-error {{friends cannot be members of the declaring class}} + friend void A::a_member(); +#if __cplusplus <= 199711L + // expected-error@-2 {{friends cannot be members of the declaring class}} +#endif friend void a_member(); // okay (because we ignore class scopes when looking up friends) friend class A::AInner; // this is okay as an extension friend class AInner; // okay, refers to ::AInner diff --git a/clang/test/CXX/class/class.friend/p2.cpp b/clang/test/CXX/class/class.friend/p2.cpp index fb3cd19b2b18..e4a46b30e788 100644 --- a/clang/test/CXX/class/class.friend/p2.cpp +++ b/clang/test/CXX/class/class.friend/p2.cpp @@ -1,10 +1,18 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s struct B0; class A { friend class B {}; // expected-error {{cannot define a type in a friend declaration}} - friend int; // expected-warning {{non-class friend type 'int' is a C++11 extension}} - friend B0; // expected-warning {{specify 'struct' to befriend 'B0'}} + friend int; +#if __cplusplus <= 199711L + // expected-warning@-2 {{non-class friend type 'int' is a C++11 extension}} +#endif + friend B0; +#if __cplusplus <= 199711L + // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'struct' to befriend 'B0'}} +#endif friend class C; // okay }; diff --git a/clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp b/clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp index 4bcc648e84aa..03c835b21a62 100644 --- a/clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp +++ b/clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // PR10034 struct X {}; @@ -40,8 +42,16 @@ struct Z { }; void test_Z() { - goto end; // expected-error{{cannot jump from this goto statement to its label}} - Z z; // expected-note{{jump bypasses initialization of non-POD variable}} + goto end; +#if __cplusplus <= 199711L + // expected-error@-2 {{cannot jump from this goto statement to its label}} +#endif + + Z z; +#if __cplusplus <= 199711L + // expected-note@-2 {{jump bypasses initialization of non-POD variable}} +#endif + end: return; } diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp index 22ea018842d4..6b87c6688a8a 100644 --- a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp +++ b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu %s +// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu -std=c++11 %s // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -triple=x86_64-linux-gnu %s -DCPP11ONLY // C++11 [temp.arg.nontype]p1: @@ -31,43 +33,103 @@ namespace non_type_tmpl_param { // if the corresopnding template-parameter is a reference; or namespace addr_of_obj_or_func { template struct X0 { }; // expected-note 5{{here}} +#if __cplusplus >= 201103L + // expected-note@-2 2{{template parameter is declared here}} +#endif + template struct X1 { }; template struct X2 { }; // expected-note 4{{here}} template struct X2k { }; // expected-note {{here}} template struct X3 { }; // expected-note 4{{here}} int i = 42; +#if __cplusplus >= 201103L + // expected-note@-2 {{declared here}} +#endif + int iarr[10]; int f(int i); - const int ki = 9; // expected-note 5{{here}} - __thread int ti = 100; // expected-note 2{{here}} - static int f_internal(int); // expected-note 4{{here}} + const int ki = 9; +#if __cplusplus <= 199711L + // expected-note@-2 5{{non-type template argument refers to object here}} +#endif + + __thread int ti = 100; // expected-note {{here}} +#if __cplusplus <= 199711L + // expected-note@-2 {{here}} +#endif + + static int f_internal(int); +#if __cplusplus <= 199711L + // expected-note@-2 4{{non-type template argument refers to function here}} +#endif + template T f_tmpl(T t); struct S { union { int NonStaticMember; }; }; void test() { - X0 x0a; // expected-error {{must have its address taken}} + X0 x0a; +#if __cplusplus <= 199711L + // expected-error@-2 {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} +#else + // expected-error@-4 {{non-type template argument of type 'int' is not a constant expression}} + // expected-note@-5 {{read of non-const variable 'i' is not allowed in a constant expression}} +#endif X0<&i> x0a_addr; X0 x0b; X0<&iarr> x0b_addr; // expected-error {{cannot be converted to a value of type 'int *'}} - X0 x0c; // expected-error {{must have its address taken}} expected-warning {{internal linkage is a C++11 extension}} - X0<&ki> x0c_addr; // expected-error {{cannot be converted to a value of type 'int *'}} expected-warning {{internal linkage is a C++11 extension}} - X0<&ti> x0d_addr; // expected-error {{refers to thread-local object}} + X0 x0c; // expected-error {{must have its address taken}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{internal linkage is a C++11 extension}} +#endif + + X0<&ki> x0c_addr; // expected-error {{cannot be converted to a value of type 'int *'}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{internal linkage is a C++11 extension}} +#endif + + X0<&ti> x0d_addr; +#if __cplusplus <= 199711L + // expected-error@-2 {{non-type template argument refers to thread-local object}} +#else + // expected-error@-4 {{non-type template argument of type 'int *' is not a constant expression}} +#endif + X1 x1a; X1<&f> x1a_addr; X1 x1b; X1<&f_tmpl> x1b_addr; X1 > x1c; X1<&f_tmpl > x1c_addr; - X1 x1d; // expected-warning {{internal linkage is a C++11 extension}} - X1<&f_internal> x1d_addr; // expected-warning {{internal linkage is a C++11 extension}} + X1 x1d; +#if __cplusplus <= 199711L + // expected-warning@-2 {{internal linkage is a C++11 extension}} +#endif + + X1<&f_internal> x1d_addr; +#if __cplusplus <= 199711L + // expected-warning@-2 {{internal linkage is a C++11 extension}} +#endif + X2 x2a; X2<&i> x2a_addr; // expected-error {{address taken}} X2 x2b; // expected-error {{cannot bind to template argument of type 'int [10]'}} X2<&iarr> x2b_addr; // expected-error {{address taken}} - X2 x2c; // expected-error {{ignores qualifiers}} expected-warning {{internal linkage is a C++11 extension}} - X2k x2kc; // expected-warning {{internal linkage is a C++11 extension}} - X2k<&ki> x2kc_addr; // expected-error {{address taken}} expected-warning {{internal linkage is a C++11 extension}} + X2 x2c; // expected-error {{ignores qualifiers}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{internal linkage is a C++11 extension}} +#endif + + X2k x2kc; +#if __cplusplus <= 199711L + // expected-warning@-2 {{internal linkage is a C++11 extension}} +#endif + + X2k<&ki> x2kc_addr; // expected-error {{address taken}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{internal linkage is a C++11 extension}} +#endif + X2 x2d_addr; // expected-error {{refers to thread-local object}} X3 x3a; X3<&f> x3a_addr; // expected-error {{address taken}} @@ -75,11 +137,31 @@ namespace addr_of_obj_or_func { X3<&f_tmpl> x3b_addr; // expected-error {{address taken}} X3 > x3c; X3<&f_tmpl > x3c_addr; // expected-error {{address taken}} - X3 x3d; // expected-warning {{internal linkage is a C++11 extension}} - X3<&f_internal> x3d_addr; // expected-error {{address taken}} expected-warning {{internal linkage is a C++11 extension}} + X3 x3d; +#if __cplusplus <= 199711L + // expected-warning@-2 {{internal linkage is a C++11 extension}} +#endif + + X3<&f_internal> x3d_addr; // expected-error {{address taken}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{internal linkage is a C++11 extension}} +#endif + + int n; +#if __cplusplus <= 199711L + // expected-note@-2 {{non-type template argument refers to object here}} +#else + // expected-note@-4 {{declared here}} +#endif + + X0<&n> x0_no_linkage; +#if __cplusplus <= 199711L + // expected-error@-2 {{non-type template argument refers to object 'n' that does not have linkage}} +#else + // expected-error@-4 {{non-type template argument of type 'int *' is not a constant expression}} + // expected-note@-5 {{pointer to 'n' is not a constant expression}} +#endif - int n; // expected-note {{here}} - X0<&n> x0_no_linkage; // expected-error {{non-type template argument refers to object 'n' that does not have linkage}} struct Local { static int f() {} }; // expected-note {{here}} X1<&Local::f> x1_no_linkage; // expected-error {{non-type template argument refers to function 'f' that does not have linkage}} X0<&S::NonStaticMember> x0_non_static; // expected-error {{non-static data member}} @@ -96,7 +178,17 @@ namespace bad_args { int i = 42; X0<&i + 2> x0a; // expected-error{{non-type template argument does not refer to any declaration}} int* iptr = &i; - X0 x0b; // expected-error{{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} +#if __cplusplus >= 201103L + // expected-note@-2 {{declared here}} +#endif + + X0 x0b; +#if __cplusplus <= 199711L + // expected-error@-2 {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} +#else + // expected-error@-4 {{non-type template argument of type 'int *' is not a constant expression}} + // expected-note@-5 {{read of non-constexpr variable 'iptr' is not allowed in a constant expression}} +#endif } #endif // CPP11ONLY @@ -108,4 +200,4 @@ int f(); } #endif // CPP11ONLY -} \ No newline at end of file +} diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp index 0fd9a7e884b9..539baecdb6a5 100644 --- a/clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp +++ b/clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + template struct A { static T t; // expected-error{{static data member instantiated with function type 'int ()'}} }; @@ -11,10 +14,17 @@ template struct B { B b; // expected-note{{instantiation of}} template int f0(void *, const T&); // expected-note{{candidate template ignored: substitution failure}} -enum {e}; // expected-note{{unnamed type used in template argument was declared here}} +enum {e}; +#if __cplusplus <= 199711L +// expected-note@-2 {{unnamed type used in template argument was declared here}} +#endif void test_f0(int n) { - int i = f0(0, e); // expected-warning{{template argument uses unnamed type}} + int i = f0(0, e); +#if __cplusplus <= 199711L + // expected-warning@-2 {{template argument uses unnamed type}} +#endif + int vla[n]; f0(0, vla); // expected-error{{no matching function for call to 'f0'}} } @@ -23,20 +33,50 @@ namespace N0 { template void f0(R (*)(A1)); template int f1(T); template int f1(T, U); - enum {e1}; // expected-note 2{{unnamed type used in template argument was declared here}} - enum {e2}; // expected-note 2{{unnamed type used in template argument was declared here}} - enum {e3}; // expected-note{{unnamed type used in template argument was declared here}} + enum {e1}; +#if __cplusplus <= 199711L + // expected-note@-2 2{{unnamed type used in template argument was declared here}} +#endif + + enum {e2}; +#if __cplusplus <= 199711L + // expected-note@-2 2{{unnamed type used in template argument was declared here}} +#endif + + enum {e3}; +#if __cplusplus <= 199711L + // expected-note@-2 {{unnamed type used in template argument was declared here}} +#endif template struct X; template struct X { }; void f() { - f0( // expected-warning{{template argument uses unnamed type}} - &f1<__typeof__(e1)>); // expected-warning{{template argument uses unnamed type}} - int (*fp1)(int, __typeof__(e2)) = f1; // expected-warning{{template argument uses unnamed type}} - f1(e2); // expected-warning{{template argument uses unnamed type}} + f0( +#if __cplusplus <= 199711L + // expected-warning@-2 {{template argument uses unnamed type}} +#endif + + &f1<__typeof__(e1)>); +#if __cplusplus <= 199711L + // expected-warning@-2 {{template argument uses unnamed type}} +#endif + + int (*fp1)(int, __typeof__(e2)) = f1; +#if __cplusplus <= 199711L + // expected-warning@-2 {{template argument uses unnamed type}} +#endif + + f1(e2); +#if __cplusplus <= 199711L + // expected-warning@-2 {{template argument uses unnamed type}} +#endif + f1(e2); - X<__typeof__(e3)*> x; // expected-warning{{template argument uses unnamed type}} + X<__typeof__(e3)*> x; +#if __cplusplus <= 199711L + // expected-warning@-2 {{template argument uses unnamed type}} +#endif } } diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp index c27261c96b68..9fd3df59d103 100644 --- a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp +++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp @@ -1,9 +1,22 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -template int f(int); // expected-note 2{{candidate}} -template int f(int); // expected-note 2{{candidate}} -int i1 = f<1>(0); // expected-error{{ambiguous}} -int i2 = f<1000>(0); // expected-error{{ambiguous}} +template int f(int); // expected-note {{candidate function}} +#if __cplusplus <= 199711L +// expected-note@-2 {{candidate function}} +#endif + +template int f(int); // expected-note {{candidate function}} +#if __cplusplus <= 199711L +// expected-note@-2 {{candidate function}} +#endif + +int i1 = f<1>(0); // expected-error{{call to 'f' is ambiguous}} +int i2 = f<1000>(0); +#if __cplusplus <= 199711L +// expected-error@-2{{call to 'f' is ambiguous}} +#endif namespace PR6707 { template diff --git a/clang/test/CXX/temp/temp.spec/no-body.cpp b/clang/test/CXX/temp/temp.spec/no-body.cpp index 61d285b27ed2..4ec18fdf820f 100644 --- a/clang/test/CXX/temp/temp.spec/no-body.cpp +++ b/clang/test/CXX/temp/temp.spec/no-body.cpp @@ -1,17 +1,44 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // RUN: cp %s %t // RUN: not %clang_cc1 -x c++ -fixit %t -DFIXING // RUN: %clang_cc1 -x c++ %t -DFIXING template void f(T) { } +#if __cplusplus >= 201103L + // expected-note@-2 {{explicit instantiation refers here}} +#endif + template void g(T) { } +#if __cplusplus >= 201103L + // expected-note@-2 {{explicit instantiation refers here}} +#endif + template struct x { }; +#if __cplusplus >= 201103L + // expected-note@-2 {{explicit instantiation refers here}} +#endif + template struct y { }; // expected-note {{declared here}} -namespace good { +namespace good { // Only good in C++98/03 +#ifndef FIXING template void f(int); +#if __cplusplus >= 201103L + // expected-error@-2 {{explicit instantiation of 'f' must occur at global scope}} +#endif + template void g(int); +#if __cplusplus >= 201103L + // expected-error@-2 {{explicit instantiation of 'g' must occur at global scope}} +#endif + template struct x; +#if __cplusplus >= 201103L + // expected-error@-2 {{explicit instantiation of 'x' must occur at global scope}} +#endif +#endif } namespace unsupported { diff --git a/clang/test/CodeGenCXX/const-init.cpp b/clang/test/CodeGenCXX/const-init.cpp index deb923a70890..f5c9dae7ba4b 100644 --- a/clang/test/CodeGenCXX/const-init.cpp +++ b/clang/test/CodeGenCXX/const-init.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -std=c++98 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -std=c++11 -o - %s | FileCheck %s // CHECK: @a = global i32 10 int a = 10; @@ -27,8 +29,13 @@ C g0 = { C::e1 }; namespace test2 { struct A { +#if __cplusplus <= 199711L static const double d = 1.0; static const float f = d / 2; +#else + static constexpr double d = 1.0; + static constexpr float f = d / 2; +#endif static int g(); } a; diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp index 9e907f1b1c12..3cc006af23dc 100644 --- a/clang/test/Parser/cxx-class.cpp +++ b/clang/test/Parser/cxx-class.cpp @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fcxx-exceptions %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fcxx-exceptions -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fcxx-exceptions -std=c++11 %s + class C; class C { public: @@ -69,11 +72,30 @@ public; // expected-error{{expected ':'}} }; class F { - int F1 { return 1; } // expected-error{{function definition does not declare parameters}} - void F2 {} // expected-error{{function definition does not declare parameters}} + int F1 { return 1; } +#if __cplusplus <= 199711L + // expected-error@-2 {{function definition does not declare parameters}} +#else + // expected-error@-4 {{expected expression}} + // expected-error@-5 {{expected}} + // expected-note@-6 {{to match this '{'}} + // expected-error@-7 {{expected ';' after class}} +#endif + + void F2 {} +#if __cplusplus <= 199711L + // expected-error@-2 {{function definition does not declare parameters}} +#else + // expected-error@-4 {{variable has incomplete type 'void'}} + // expected-error@-5 {{expected ';' after top level declarator}} +#endif + typedef int F3() { return 0; } // expected-error{{function definition declared 'typedef'}} typedef void F4() {} // expected-error{{function definition declared 'typedef'}} }; +#if __cplusplus >= 201103L +// expected-error@-2 {{extraneous closing brace}} +#endif namespace ctor_error { class Foo {}; @@ -203,14 +225,38 @@ namespace BadFriend { } class PR20760_a { - int a = ); // expected-warning {{extension}} expected-error {{expected expression}} - int b = }; // expected-warning {{extension}} expected-error {{expected expression}} - int c = ]; // expected-warning {{extension}} expected-error {{expected expression}} + int a = ); // expected-error {{expected expression}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} +#endif + + int b = }; // expected-error {{expected expression}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} +#endif + + int c = ]; // expected-error {{expected expression}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} +#endif + }; class PR20760_b { - int d = d); // expected-warning {{extension}} expected-error {{expected ';'}} - int e = d]; // expected-warning {{extension}} expected-error {{expected ';'}} - int f = d // expected-warning {{extension}} expected-error {{expected ';'}} + int d = d); // expected-error {{expected ';'}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} +#endif + + int e = d]; // expected-error {{expected ';'}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} +#endif + + int f = d // expected-error {{expected ';'}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} +#endif + }; namespace PR20887 { diff --git a/clang/test/Parser/cxx-decl.cpp b/clang/test/Parser/cxx-decl.cpp index be79eb433fd0..8a7a38860539 100644 --- a/clang/test/Parser/cxx-decl.cpp +++ b/clang/test/Parser/cxx-decl.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions %s +// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions -std=c++98 %s +// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions -std=c++11 %s const char const *x10; // expected-error {{duplicate 'const' declaration specifier}} @@ -46,7 +48,10 @@ class asm_class_test { void foo() __asm__("baz"); }; -enum { fooenum = 1, }; // expected-error {{commas at the end of enumerator lists are a C++11 extension}} +enum { fooenum = 1, }; +#if __cplusplus <= 199711L +// expected-error@-2 {{commas at the end of enumerator lists are a C++11 extension}} +#endif struct a { int Type : fooenum; @@ -81,7 +86,11 @@ namespace Commas { (global5), *global6, &global7 = global1, - &&global8 = static_cast(global1), // expected-error 2{{rvalue reference}} + &&global8 = static_cast(global1), +#if __cplusplus <= 199711L + // expected-error@-2 2{{rvalue references are a C++11 extension}} +#endif + S::a, global9, global10 = 0, @@ -185,7 +194,13 @@ namespace PR15017 { } // Ensure we produce at least some diagnostic for attributes in C++98. -[[]] struct S; // expected-error 2{{}} +[[]] struct S; +#if __cplusplus <= 199711L +// expected-error@-2 {{expected expression}} +// expected-error@-3 {{expected unqualified-id}} +#else +// expected-error@-5 {{an attribute list cannot appear here}} +#endif namespace test7 { struct Foo { @@ -212,14 +227,20 @@ namespace PR5066 { template struct X {}; X x; // expected-error {{type-id cannot have a name}} - using T = int (*T)(); // expected-error {{type-id cannot have a name}} expected-error {{C++11}} + using T = int (*T)(); // expected-error {{type-id cannot have a name}} +#if __cplusplus <= 199711L + // expected-error@-2 {{alias declarations are a C++11 extensio}} +#endif + } namespace PR17255 { void foo() { - typename A::template B<>; // expected-error {{use of undeclared identifier 'A'}} \ - // expected-error {{expected a qualified name after 'typename'}} \ - // expected-error {{'template' keyword outside of a template}} + typename A::template B<>; // expected-error {{use of undeclared identifier 'A'}} +#if __cplusplus <= 199711L + // expected-error@-2 {{'template' keyword outside of a template}} +#endif + // expected-error@-4 {{expected a qualified name after 'typename'}} } } @@ -236,12 +257,25 @@ namespace DuplicateFriend { struct A { friend void friend f(); // expected-warning {{duplicate 'friend' declaration specifier}} friend struct B friend; // expected-warning {{duplicate 'friend' declaration specifier}} +#if __cplusplus >= 201103L + // expected-error@-2 {{'friend' must appear first in a non-function declaration}} +#endif }; } // PR8380 extern "" // expected-error {{unknown linkage language}} -test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \ - // expected-error {{expected ';' after top level declarator}} +test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} +#if __cplusplus <= 199711L +// expected-error@-2 {{expected ';' after top level declarator}} +#else +// expected-error@-4 {{expected expression}} +// expected-note@-5 {{to match this}} +#endif int test6b; +#if __cplusplus >= 201103L +// expected-error@+3 {{expected}} +// expected-error@-3 {{expected ';' after top level declarator}} +#endif + diff --git a/clang/test/Parser/cxx-friend.cpp b/clang/test/Parser/cxx-friend.cpp index ace0ff26e2d9..a4492ba1a7ab 100644 --- a/clang/test/Parser/cxx-friend.cpp +++ b/clang/test/Parser/cxx-friend.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s class C { friend class D; @@ -21,9 +23,20 @@ class B { // 'A' here should refer to the declaration above. friend class A; - friend C; // expected-warning {{specify 'class' to befriend}} - friend U; // expected-warning {{specify 'union' to befriend}} - friend int; // expected-warning {{non-class friend type 'int'}} + friend C; +#if __cplusplus <= 199711L + // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'class' to befriend 'C'}} +#endif + + friend U; +#if __cplusplus <= 199711L + // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'union' to befriend 'U'}} +#endif + + friend int; +#if __cplusplus <= 199711L + // expected-warning@-2 {{non-class friend type 'int' is a C++11 extension}} +#endif friend void myfunc(); diff --git a/clang/test/SemaCXX/anonymous-struct.cpp b/clang/test/SemaCXX/anonymous-struct.cpp index 1b5dc13cea01..b584f89ff447 100644 --- a/clang/test/SemaCXX/anonymous-struct.cpp +++ b/clang/test/SemaCXX/anonymous-struct.cpp @@ -1,7 +1,12 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s struct S { - S(); // expected-note {{because type 'S' has a user-provided default constructor}} + S(); +#if __cplusplus <= 199711L + // expected-note@-2 {{because type 'S' has a user-provided default constructor}} +#endif }; struct { // expected-error {{anonymous structs and classes must be class members}} @@ -9,15 +14,25 @@ struct { // expected-error {{anonymous structs and classes must be class members struct E { struct { - S x; // expected-error {{anonymous struct member 'x' has a non-trivial constructor}} + S x; +#if __cplusplus <= 199711L + // expected-error@-2 {{anonymous struct member 'x' has a non-trivial constructor}} +#endif }; static struct { }; }; template void foo(T); -typedef struct { // expected-note {{use a tag name here to establish linkage prior to definition}} expected-note {{declared here}} +typedef struct { // expected-note {{use a tag name here to establish linkage prior to definition}} +#if __cplusplus <= 199711L +// expected-note@-2 {{declared here}} +#endif + void test() { - foo(this); // expected-warning {{template argument uses unnamed type}} + foo(this); +#if __cplusplus <= 199711L + // expected-warning@-2 {{template argument uses unnamed type}} +#endif } } A; // expected-error {{unsupported: typedef changes linkage of anonymous type, but linkage was already computed}} diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp index a6694403a68a..a3593689b5fb 100644 --- a/clang/test/SemaCXX/class.cpp +++ b/clang/test/SemaCXX/class.cpp @@ -1,7 +1,12 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s class C { public: - auto int errx; // expected-error {{storage class specified for a member declaration}} expected-warning {{'auto' storage class specifier is redundant}} + auto int errx; // expected-error {{storage class specified for a member declaration}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{'auto' storage class specifier is redundant}} +#else + // expected-warning@-4 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} +#endif register int erry; // expected-error {{storage class specified for a member declaration}} extern int errz; // expected-error {{storage class specified for a member declaration}} @@ -36,12 +41,18 @@ public: enum E1 { en1, en2 }; - int i = 0; // expected-warning {{in-class initialization of non-static data member is a C++11 extension}} + int i = 0; +#if __cplusplus <= 199711L + // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} +#endif static int si = 0; // expected-error {{non-const static data member must be initialized out of line}} static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}} static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}} static const int vi = 0; static const volatile int cvi = 0; // ok, illegal in C++11 +#if __cplusplus >= 201103L + // expected-error@-2 {{static const volatile data member must be initialized out of line}} +#endif static const E evi = 0; void m() { @@ -169,10 +180,18 @@ namespace rdar8066414 { namespace rdar8367341 { float foo(); +#if __cplusplus >= 201103L + // expected-note@-2 {{declared here}} +#endif struct A { +#if __cplusplus <= 199711L static const float x = 5.0f; // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}} static const float y = foo(); // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}} expected-error {{in-class initializer for static data member is not a constant expression}} +#else + static constexpr float x = 5.0f; + static constexpr float y = foo(); // expected-error {{constexpr variable 'y' must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo' cannot be used in a constant expression}} +#endif }; } diff --git a/clang/test/SemaCXX/conversion-function.cpp b/clang/test/SemaCXX/conversion-function.cpp index 649f6b4dce94..3f494cce8ce3 100644 --- a/clang/test/SemaCXX/conversion-function.cpp +++ b/clang/test/SemaCXX/conversion-function.cpp @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++98 %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++11 %s + class X { public: operator bool(); @@ -133,7 +136,12 @@ private: A1 f() { // FIXME: redundant diagnostics! - return "Hello"; // expected-error {{calling a private constructor}} expected-warning {{an accessible copy constructor}} + return "Hello"; // expected-error {{calling a private constructor}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{an accessible copy constructor}} +#else + // expected-warning@-4 {{copying parameter of type 'A1' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}} +#endif } namespace source_locations { @@ -175,7 +183,13 @@ namespace crazy_declarators { (&operator bool())(); // expected-error {{use a typedef to declare a conversion to 'bool (&)()'}} *operator int(); // expected-error {{put the complete type after 'operator'}} // No suggestion of using a typedef here; that's not possible. - template (&operator T())(); // expected-error-re {{cannot specify any part of a return type in the declaration of a conversion function{{$}}}} + template (&operator T())(); +#if __cplusplus <= 199711L + // expected-error-re@-2 {{cannot specify any part of a return type in the declaration of a conversion function{{$}}}} +#else + // expected-error-re@-4 {{cannot specify any part of a return type in the declaration of a conversion function; use an alias template to declare a conversion to 'T (&)()'{{$}}}} +#endif + }; } @@ -193,6 +207,10 @@ namespace smart_ptr { }; struct X { // expected-note{{candidate constructor (the implicit copy constructor) not}} +#if __cplusplus >= 201103L + // expected-note@-2 {{candidate constructor (the implicit move constructor) not}} +#endif + explicit X(Y); }; @@ -215,7 +233,12 @@ struct Other { }; void test_any() { - Any any = Other(); // expected-error{{cannot pass object of non-POD type 'Other' through variadic constructor; call will abort at runtime}} + Any any = Other(); +#if __cplusplus <= 199711L + // expected-error@-2 {{cannot pass object of non-POD type 'Other' through variadic constructor; call will abort at runtime}} +#else + // expected-error@-4 {{cannot pass object of non-trivial type 'Other' through variadic constructor; call will abort at runtime}} +#endif } namespace PR7055 { diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp index 1c59585b3258..e2fbdfd69954 100644 --- a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp +++ b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -fsyntax-only %s -Wno-c++11-extensions -Wno-c++1y-extensions -DPRECXX11 +// RUN: %clang_cc1 -std=c++98 -verify -fsyntax-only %s -Wno-c++11-extensions -Wno-c++1y-extensions -DPRECXX11 // RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s -DCPP1Y diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp index 787868fae176..1e5c98beb9cb 100644 --- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp +++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -fsyntax-only -Wno-c++11-extensions -Wno-c++1y-extensions %s -DPRECXX11 +// RUN: %clang_cc1 -std=c++98 -verify -fsyntax-only -Wno-c++11-extensions -Wno-c++1y-extensions %s -DPRECXX11 // RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s diff --git a/clang/test/SemaCXX/exceptions.cpp b/clang/test/SemaCXX/exceptions.cpp index 9802a1a1d620..05793e2ffc84 100644 --- a/clang/test/SemaCXX/exceptions.cpp +++ b/clang/test/SemaCXX/exceptions.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s struct A; // expected-note 4 {{forward declaration of 'A'}} @@ -135,16 +137,29 @@ namespace Decay { void f() throw (int*, int()); template struct C { - void f() throw (T); // expected-error {{pointer to incomplete type 'Decay::E' is not allowed in exception specification}} + void f() throw (T); +#if __cplusplus <= 199711L + // expected-error@-2 {{pointer to incomplete type 'Decay::E' is not allowed in exception specification}} +#endif }; struct D { C c; }; - struct E; // expected-note {{forward declaration}} - C e; // expected-note {{in instantiation of}} + struct E; +#if __cplusplus <= 199711L + // expected-note@-2 {{forward declaration of 'Decay::E'}} +#endif + + C e; +#if __cplusplus <= 199711L + // expected-note@-2 {{in instantiation of template class 'Decay::C' requested here}} +#endif } -void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int &&' is not allowed in exception specification}} expected-warning {{C++11}} +void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int &&' is not allowed in exception specification}} +#if __cplusplus <= 199711L +// expected-warning@-2 {{rvalue references are a C++11 extension}} +#endif namespace HandlerInversion { struct B {}; diff --git a/clang/test/SemaCXX/qual-id-test.cpp b/clang/test/SemaCXX/qual-id-test.cpp index 9994d75cac19..61e60ae82dfa 100644 --- a/clang/test/SemaCXX/qual-id-test.cpp +++ b/clang/test/SemaCXX/qual-id-test.cpp @@ -1,9 +1,15 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + namespace A { namespace B { - struct base // expected-note{{object type}} + struct base +#if __cplusplus <= 199711L + // expected-note@-2 {{lookup in the object type 'A::sub' refers here}} +#endif { void x() {} void y() {} @@ -85,8 +91,14 @@ namespace C void fun4a() { A::sub *a; - typedef A::member base; // expected-note{{current scope}} - a->base::x(); // expected-error{{ambiguous}} + typedef A::member base; +#if __cplusplus <= 199711L + // expected-note@-2 {{lookup from the current scope refers here}} +#endif + a->base::x(); +#if __cplusplus <= 199711L + // expected-error@-2 {{lookup of 'base' in member access expression is ambiguous}} +#endif } void fun4b() { diff --git a/clang/test/SemaCXX/unused.cpp b/clang/test/SemaCXX/unused.cpp index fbaf8c8bf3c1..09a179e7bb85 100644 --- a/clang/test/SemaCXX/unused.cpp +++ b/clang/test/SemaCXX/unused.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // PR4103 : Make sure we don't get a bogus unused expression warning namespace PR4103 { @@ -28,8 +30,14 @@ namespace PR4103 { namespace derefvolatile { void f(volatile char* x) { - *x; // expected-warning {{expression result unused; assign into a variable to force a volatile load}} - (void)*x; // expected-warning {{expression result unused; assign into a variable to force a volatile load}} + *x; +#if __cplusplus <= 199711L + // expected-warning@-2 {{expression result unused; assign into a variable to force a volatile load}} +#endif + (void)*x; +#if __cplusplus <= 199711L + // expected-warning@-2 {{expression result unused; assign into a variable to force a volatile load}} +#endif volatile char y = 10; (void)y; // don't warn here, because it's a common pattern. } diff --git a/clang/test/SemaCXX/warn-unused-value.cpp b/clang/test/SemaCXX/warn-unused-value.cpp index efabd5063068..d6ec0fb5d1cd 100644 --- a/clang/test/SemaCXX/warn-unused-value.cpp +++ b/clang/test/SemaCXX/warn-unused-value.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++11 %s // PR4806 namespace test0 { @@ -12,7 +14,10 @@ namespace test0 { // pointer to volatile has side effect (thus no warning) Box* box = new Box; box->i; // expected-warning {{expression result unused}} - box->j; // expected-warning {{expression result unused}} + box->j; +#if __cplusplus <= 199711L + // expected-warning@-2 {{expression result unused}} +#endif } } diff --git a/clang/test/SemaTemplate/member-access-expr.cpp b/clang/test/SemaTemplate/member-access-expr.cpp index f1aa30ec32a6..8dba2e68d656 100644 --- a/clang/test/SemaTemplate/member-access-expr.cpp +++ b/clang/test/SemaTemplate/member-access-expr.cpp @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + template void call_f0(T x) { x.Base::f0(); @@ -28,15 +31,25 @@ void test_f0_through_typedef(X0 x0) { template void call_f0_through_typedef2(T x) { - typedef TheBase CrazyBase; // expected-note{{current scope}} - x.CrazyBase::f0(); // expected-error{{ambiguous}} \ - // expected-error 2{{no member named}} + typedef TheBase CrazyBase; +#if __cplusplus <= 199711L + // expected-note@-2 {{lookup from the current scope refers here}} +#endif + + x.CrazyBase::f0(); // expected-error 2{{no member named}} +#if __cplusplus <= 199711L + // expected-error@-2 {{lookup of 'CrazyBase' in member access expression is ambiguous}} +#endif + } struct OtherBase { }; struct X1 : Base, OtherBase { - typedef OtherBase CrazyBase; // expected-note{{object type}} + typedef OtherBase CrazyBase; +#if __cplusplus <= 199711L + // expected-note@-2 {{lookup in the object type 'X1' refers here}} +#endif }; void test_f0_through_typedef2(X0 x0, X1 x1) { diff --git a/clang/test/SemaTemplate/recovery-crash.cpp b/clang/test/SemaTemplate/recovery-crash.cpp index 02f80495bb94..c8e783f47b45 100644 --- a/clang/test/SemaTemplate/recovery-crash.cpp +++ b/clang/test/SemaTemplate/recovery-crash.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // Clang used to crash trying to recover while adding 'this->' before Work(x); @@ -25,14 +27,20 @@ namespace PR16134 { namespace PR16225 { template void f(); - template void g(C*) { + template void g(C*) { struct LocalStruct : UnknownBase { }; // expected-error {{unknown template name 'UnknownBase'}} \ // expected-error {{use of undeclared identifier 'Mumble'}} - f(); // expected-warning {{template argument uses local type 'LocalStruct'}} + f(); +#if __cplusplus <= 199711L + // expected-warning@-2 {{template argument uses local type 'LocalStruct'}} +#endif } struct S; void h() { - g(0); // expected-note {{in instantiation of function template specialization}} + g(0); +#if __cplusplus <= 199711L + // expected-note@-2 {{in instantiation of function template specialization}} +#endif } } diff --git a/clang/test/SemaTemplate/temp_arg_type.cpp b/clang/test/SemaTemplate/temp_arg_type.cpp index 637b5637baec..daad61c14292 100644 --- a/clang/test/SemaTemplate/temp_arg_type.cpp +++ b/clang/test/SemaTemplate/temp_arg_type.cpp @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + template class A; // expected-note 2 {{template parameter is declared here}} expected-note{{template is declared here}} // [temp.arg.type]p1 @@ -24,11 +27,21 @@ A a8; // expected-error{{use of class template 'ns::B' requires template // [temp.arg.type]p2 void f() { class X { }; - A * a = 0; // expected-warning{{template argument uses local type 'X'}} + A * a = 0; +#if __cplusplus <= 199711L + // expected-warning@-2 {{template argument uses local type 'X'}} +#endif } -struct { int x; } Unnamed; // expected-note{{unnamed type used in template argument was declared here}} -A<__typeof__(Unnamed)> *a9; // expected-warning{{template argument uses unnamed type}} +struct { int x; } Unnamed; +#if __cplusplus <= 199711L +// expected-note@-2 {{unnamed type used in template argument was declared here}} +#endif + +A<__typeof__(Unnamed)> *a9; +#if __cplusplus <= 199711L +// expected-warning@-2 {{template argument uses unnamed type}} +#endif template struct Array {