Index: test/CodeGenCXX/debug-info-use-after-free.cpp =================================================================== --- test/CodeGenCXX/debug-info-use-after-free.cpp +++ test/CodeGenCXX/debug-info-use-after-free.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only %s +// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only -std=c++98 %s +// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only -std=c++11 %s // Check that we don't crash. // PR12305, PR12315 @@ -233,6 +235,7 @@ namespace { class AAA { +protected: virtual ~ AAA () { }}; Index: test/CodeGenCXX/dynamic-cast-hint.cpp =================================================================== --- test/CodeGenCXX/dynamic-cast-hint.cpp +++ test/CodeGenCXX/dynamic-cast-hint.cpp @@ -1,7 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -std=c++98 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -std=c++11 -o - %s | FileCheck %s -class A { virtual ~A() {} }; -class B { virtual ~B() {} }; +class A { protected: virtual ~A() {} }; +class B { protected: virtual ~B() {} }; class C : A { char x; }; class D : public A { short y; }; Index: test/OpenMP/distribute_collapse_messages.cpp =================================================================== --- test/OpenMP/distribute_collapse_messages.cpp +++ test/OpenMP/distribute_collapse_messages.cpp @@ -1,8 +1,13 @@ // RUN: %clang_cc1 -verify -fopenmp %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s void foo() { } +#if __cplusplus >= 201103L + // expected-note@+2 4 {{declared here}} +#endif bool foobool(int argc) { return argc; } @@ -29,6 +34,9 @@ for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; #pragma omp distribute collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp distribute', but found only 1}} +#if __cplusplus >= 201103L + // expected-note@+5 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif // expected-error@+3 2 {{directive '#pragma omp distribute' cannot contain more than one 'collapse' clause}} // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} // expected-error@+1 2 {{expression is not an integral constant expression}} @@ -36,7 +44,11 @@ for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; #pragma omp distribute collapse (S) // expected-error {{'S' does not refer to a value}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; - // expected-error@+1 2 {{expression is not an integral constant expression}} +#if __cplusplus <= 199711L + // expected-error@+4 2 {{expression is not an integral constant expression}} +#else + // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#endif #pragma omp distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; #pragma omp distribute collapse (1) @@ -59,8 +71,14 @@ for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute', but found only 1}} #pragma omp distribute collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp distribute' are ignored}} expected-note {{as specified in 'collapse' clause}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute', but found only 1}} +#if __cplusplus >= 201103L + // expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif #pragma omp distribute collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; +#if __cplusplus >= 201103L + // expected-note@+5 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif // expected-error@+3 {{expression is not an integral constant expression}} // expected-error@+2 2 {{directive '#pragma omp distribute' cannot contain more than one 'collapse' clause}} // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}} @@ -68,7 +86,11 @@ for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; #pragma omp distribute collapse (S1) // expected-error {{'S1' does not refer to a value}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; - // expected-error@+1 {{expression is not an integral constant expression}} +#if __cplusplus <= 199711L + // expected-error@+4 {{expression is not an integral constant expression}} +#else + // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#endif #pragma omp distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error@+3 {{statement after '#pragma omp distribute' must be a for loop}} Index: test/OpenMP/ordered_messages.cpp =================================================================== --- test/OpenMP/ordered_messages.cpp +++ test/OpenMP/ordered_messages.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 -o - %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s int foo(); @@ -123,6 +125,9 @@ #pragma omp ordered depend(sink : j, i) // expected-error {{expected 'i' loop iteration variable}} expected-error {{expected 'j' loop iteration variable}} #pragma omp ordered depend(sink : i, j, k) // expected-error {{unexpected expression: number of expressions is larger than the number of associated loops}} #pragma omp ordered depend(sink : i+foo(), j/4) // expected-error {{expression is not an integral constant expression}} expected-error {{expected '+' or '-' operation}} +#if __cplusplus >= 201103L +// expected-note@-2 {{non-constexpr function 'foo' cannot be used in a constant expression}} +#endif #pragma omp ordered depend(sink : i*0, j-4)// expected-error {{expected '+' or '-' operation}} #pragma omp ordered depend(sink : i-0, j+sizeof(T)) depend(sink : i-0, j+sizeof(T)) #pragma omp ordered depend(sink : i-0, j+sizeof(T)) depend(source) // expected-error {{'depend(source)' clause cannot be mixed with 'depend(sink:vec)' clauses}} @@ -133,6 +138,9 @@ } int foo() { +#if __cplusplus >= 201103L +// expected-note@-2 2 {{declared here}} +#endif int k; #pragma omp for ordered for (int i = 0; i < 10; ++i) { @@ -252,6 +260,9 @@ #pragma omp ordered depend(sink : j, i) // expected-error {{expected 'i' loop iteration variable}} expected-error {{expected 'j' loop iteration variable}} #pragma omp ordered depend(sink : i, j, k) // expected-error {{unexpected expression: number of expressions is larger than the number of associated loops}} #pragma omp ordered depend(sink : i+foo(), j/4) // expected-error {{expression is not an integral constant expression}} expected-error {{expected '+' or '-' operation}} +#if __cplusplus >= 201103L +// expected-note@-2 {{non-constexpr function 'foo' cannot be used in a constant expression}} +#endif #pragma omp ordered depend(sink : i*0, j-4)// expected-error {{expected '+' or '-' operation}} #pragma omp ordered depend(sink : i-0, j+sizeof(int)) depend(sink : i-0, j+sizeof(int)) #pragma omp ordered depend(sink : i-0, j+sizeof(int)) depend(source) // expected-error {{'depend(source)' clause cannot be mixed with 'depend(sink:vec)' clauses}} Index: test/OpenMP/target_parallel_for_collapse_messages.cpp =================================================================== --- test/OpenMP/target_parallel_for_collapse_messages.cpp +++ test/OpenMP/target_parallel_for_collapse_messages.cpp @@ -1,9 +1,14 @@ // RUN: %clang_cc1 -verify -fopenmp %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s void foo() { } bool foobool(int argc) { +#if __cplusplus >= 201103L +// expected-note@-2 4 {{declared here}} +#endif return argc; } @@ -33,10 +38,17 @@ // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} // expected-error@+1 2 {{expression is not an integral constant expression}} #pragma omp target parallel for collapse (foobool(argc)), collapse (true), collapse (-5) +#if __cplusplus >= 201103L +// expected-note@-2 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; #pragma omp target parallel for collapse (S) // expected-error {{'S' does not refer to a value}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; - // expected-error@+1 2 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#else + // expected-error@+2 2 {{expression is not an integral constant expression}} +#endif #pragma omp target parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; #pragma omp target parallel for collapse (1) @@ -60,15 +72,25 @@ #pragma omp target parallel for collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} expected-note {{as specified in 'collapse' clause}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target parallel for', but found only 1}} #pragma omp target parallel for collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L +// expected-note@-2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error@+3 {{expression is not an integral constant expression}} // expected-error@+2 2 {{directive '#pragma omp target parallel for' cannot contain more than one 'collapse' clause}} // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}} #pragma omp target parallel for collapse (foobool(argc)), collapse (true), collapse (-5) +#if __cplusplus >= 201103L +// expected-note@-2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; #pragma omp target parallel for collapse (S1) // expected-error {{'S1' does not refer to a value}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; - // expected-error@+1 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#else + // expected-error@+2 {{expression is not an integral constant expression}} +#endif #pragma omp target parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error@+3 {{statement after '#pragma omp target parallel for' must be a for loop}} Index: test/OpenMP/target_parallel_for_ordered_messages.cpp =================================================================== --- test/OpenMP/target_parallel_for_ordered_messages.cpp +++ test/OpenMP/target_parallel_for_ordered_messages.cpp @@ -1,9 +1,14 @@ // RUN: %clang_cc1 -verify -fopenmp %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s void foo() { } bool foobool(int argc) { +#if __cplusplus >= 201103L +// expected-note@-2 4 {{declared here}} +#endif return argc; } @@ -36,6 +41,9 @@ #pragma omp target parallel for ordered((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'ordered' clause}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i - ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp target parallel for', but found only 1}} +#if __cplusplus >= 201103L +// expected-note@+5 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif // expected-error@+3 2 {{directive '#pragma omp target parallel for' cannot contain more than one 'ordered' clause}} // expected-error@+2 2 {{argument to 'ordered' clause must be a strictly positive integer value}} // expected-error@+1 2 {{expression is not an integral constant expression}} @@ -45,7 +53,11 @@ #pragma omp target parallel for ordered(S) // expected-error {{'S' does not refer to a value}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i - ST]; -// expected-error@+1 2 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#else + // expected-error@+2 2 {{expression is not an integral constant expression}} +#endif #pragma omp target parallel for ordered(argv[1] = 2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i - ST]; @@ -76,9 +88,15 @@ #pragma omp target parallel for ordered(2 + 2)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} expected-note {{as specified in 'ordered' clause}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i - 4]; // expected-error {{expected 4 for loops after '#pragma omp target parallel for', but found only 1}} +#if __cplusplus >= 201103L +// expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif #pragma omp target parallel for ordered(foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i - 4]; +#if __cplusplus >= 201103L +// expected-note@+5 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif // expected-error@+3 {{expression is not an integral constant expression}} // expected-error@+2 2 {{directive '#pragma omp target parallel for' cannot contain more than one 'ordered' clause}} // expected-error@+1 2 {{argument to 'ordered' clause must be a strictly positive integer value}} @@ -88,7 +106,11 @@ #pragma omp target parallel for ordered(S1) // expected-error {{'S1' does not refer to a value}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i - 4]; -// expected-error@+1 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#else + // expected-error@+2 {{expression is not an integral constant expression}} +#endif #pragma omp target parallel for ordered(argv[1] = 2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i - 4]; Index: test/SemaCXX/i-c-e-cxx.cpp =================================================================== --- test/SemaCXX/i-c-e-cxx.cpp +++ test/SemaCXX/i-c-e-cxx.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=gnu++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=gnu++11 %s // C++-specific tests for integral constant expressions. @@ -16,9 +18,21 @@ } int a() { - const int t=t; // expected-note {{declared here}} expected-note {{read of object outside its lifetime}} - switch(1) { // expected-warning {{no case matching constant switch condition '1'}} - case t:; // expected-error {{not an integral constant expression}} expected-note {{initializer of 't' is not a constant expression}} + const int t=t; // expected-note {{declared here}} +#if __cplusplus <= 199711L + // expected-note@-2 {{read of object outside its lifetime}} +#endif + + switch(1) { +#if __cplusplus <= 199711L + // expected-warning@-2 {{no case matching constant switch condition '1'}} +#endif + case t:; // expected-note {{initializer of 't' is not a constant expression}} +#if __cplusplus <= 199711L + // expected-error@-2 {{not an integral constant expression}} +#else + // expected-error@-4 {{case value is not a constant expression}} +#endif } } @@ -48,7 +62,10 @@ namespace rdar9204520 { struct A { - static const int B = int(0.75 * 1000 * 1000); // expected-warning {{not a constant expression; folding it to a constant is a GNU extension}} + static const int B = int(0.75 * 1000 * 1000); +#if __cplusplus <= 199711L + // expected-warning@-2 {{not a constant expression; folding it to a constant is a GNU extension}} +#endif }; int foo() { return A::B; } @@ -59,10 +76,24 @@ int* y = reinterpret_cast(x); // expected-error {{cannot initialize}} // This isn't an integral constant expression, but make sure it folds anyway. -struct PR8836 { char _; long long a; }; // expected-warning {{long long}} -int PR8836test[(__typeof(sizeof(int)))&reinterpret_cast((((PR8836*)0)->a))]; // expected-warning {{folded to constant array as an extension}} expected-note {{cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression}} +struct PR8836 { char _; long long a; }; +#if __cplusplus <= 199711L +// expected-warning@-2 {{'long long' is a C++11 extension}} +#endif + +int PR8836test[(__typeof(sizeof(int)))&reinterpret_cast((((PR8836*)0)->a))]; +// expected-warning@-1 {{folded to constant array as an extension}} +// expected-note@-2 {{cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression}} + +const int nonconst = 1.0; +#if __cplusplus <= 199711L +// expected-note@-2 {{declared here}} +#endif +int arr[nonconst]; +#if __cplusplus <= 199711L +// expected-warning@-2 {{folded to constant array as an extension}} +// expected-note@-3 {{initializer of 'nonconst' is not a constant expression}} +#endif -const int nonconst = 1.0; // expected-note {{declared here}} -int arr[nonconst]; // expected-warning {{folded to constant array as an extension}} expected-note {{initializer of 'nonconst' is not a constant expression}} const int castfloat = static_cast(1.0); int arr2[castfloat]; // ok Index: test/SemaCXX/implicit-virtual-member-functions.cpp =================================================================== --- test/SemaCXX/implicit-virtual-member-functions.cpp +++ test/SemaCXX/implicit-virtual-member-functions.cpp @@ -1,33 +1,87 @@ // RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s +// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++11 %s // RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s +// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++11 %s + struct A { virtual ~A(); +#if __cplusplus >= 201103L +// expected-note@-2 3 {{overridden virtual function is here}} +#endif }; -struct B : A { // expected-error {{no suitable member 'operator delete' in 'B'}} +struct B : A { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'B'}} +#else +// expected-error@-4 {{deleted function '~B' cannot override a non-deleted function}} +// expected-note@-5 {{virtual destructor requires an unambiguous, accessible 'operator delete'}} +#ifdef MSABI +// expected-note@-7 {{virtual destructor requires an unambiguous, accessible 'operator delete'}} +#endif +#endif virtual void f(); - void operator delete (void *, int); // expected-note {{'operator delete' declared here}} + void operator delete (void *, int); +#if __cplusplus <= 199711L +// expected-note@-2 {{'operator delete' declared here}} +#endif }; #ifdef MSABI -B b; // expected-note {{implicit destructor for 'B' first required here}} +B b; +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'B' first required here}} +#else +// expected-error@-4 {{attempt to use a deleted function}} +#endif + #else -void B::f() { // expected-note {{implicit destructor for 'B' first required here}} +void B::f() { +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'B' first required here}} +#endif } #endif -struct C : A { // expected-error {{no suitable member 'operator delete' in 'C'}} +struct C : A { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'C'}} +#else +// expected-error@-4 {{deleted function '~C' cannot override a non-deleted function}} +// expected-note@-5 {{virtual destructor requires an unambiguous, accessible 'operator delete'}} +#endif + C(); - void operator delete(void *, int); // expected-note {{'operator delete' declared here}} + void operator delete(void *, int); +#if __cplusplus <= 199711L +// expected-note@-2 {{'operator delete' declared here}} +#endif }; -C::C() { } // expected-note {{implicit destructor for 'C' first required here}} +C::C() { } +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'C' first required here}} +#endif -struct D : A { // expected-error {{no suitable member 'operator delete' in 'D'}} - void operator delete(void *, int); // expected-note {{'operator delete' declared here}} +struct D : A { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'D'}} +#else +// expected-error@-4 {{deleted function '~D' cannot override a non-deleted function}} +// expected-note@-5 {{virtual destructor requires an unambiguous, accessible 'operator delete'}} +#endif + void operator delete(void *, int); +#if __cplusplus <= 199711L +// expected-note@-2 {{'operator delete' declared here}} +#endif }; void f() { - new D; // expected-note {{implicit destructor for 'D' first required here}} + new D; +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'D' first required here}} +#endif } Index: test/SemaCXX/new-delete.cpp =================================================================== --- test/SemaCXX/new-delete.cpp +++ test/SemaCXX/new-delete.cpp @@ -1,7 +1,12 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -Wno-new-returns-null +// RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++98 +// RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++11 #include +#if __cplusplus >= 201103L +// expected-note@+2 {{candidate constructor (the implicit move constructor) not viable}} +#endif struct S // expected-note {{candidate}} { S(int, int, double); // expected-note {{candidate}} @@ -72,7 +77,13 @@ (void)new; // expected-error {{expected a type}} (void)new 4; // expected-error {{expected a type}} (void)new () int; // expected-error {{expected expression}} - (void)new int[1.1]; // expected-error {{array size expression must have integral or enumeration type, not 'double'}} + (void)new int[1.1]; +#if __cplusplus <= 199711L + // expected-error@-2 {{array size expression must have integral or enumeration type, not 'double'}} +#else + // expected-error@-4 {{array size expression must have integral or unscoped enumeration type, not 'double'}} +#endif + (void)new int[1][i]; // expected-error {{only the first dimension}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}} (void)new (int[1][i]); // expected-error {{only the first dimension}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}} (void)new (int[i]); // expected-warning {{when type is in parentheses}} @@ -85,7 +96,13 @@ // Undefined, but clang should reject it directly. (void)new int[-1]; // expected-error {{array size is negative}} (void)new int[2000000000]; // expected-error {{array is too large}} - (void)new int[*(S*)0]; // expected-error {{array size expression must have integral or enumeration type, not 'S'}} + (void)new int[*(S*)0]; +#if __cplusplus <= 199711L + // expected-error@-2 {{array size expression must have integral or enumeration type, not 'S'}} +#else + // expected-error@-4 {{array size expression must have integral or unscoped enumeration type, not 'S'}} +#endif + (void)::S::new int; // expected-error {{expected unqualified-id}} (void)new (0, 0) int; // expected-error {{no matching function for call to 'operator new'}} (void)new (0L) int; // expected-error {{call to 'operator new' is ambiguous}} @@ -109,7 +126,12 @@ void bad_deletes() { delete 0; // expected-error {{cannot delete expression of type 'int'}} - delete [0] (int*)0; // expected-error {{expected expression}} + delete [0] (int*)0; +#if __cplusplus <= 199711L + // expected-error@-2 {{expected expression}} +#else + // expected-error@-4 {{expected variable name or 'this' in lambda capture list}} +#endif delete (void*)0; // expected-warning {{cannot delete expression with pointer-to-'void' type 'void *'}} delete (T*)0; // expected-warning {{deleting pointer to incomplete type}} ::S::delete (int*)0; // expected-error {{expected unqualified-id}} @@ -209,14 +231,31 @@ struct X10 { virtual ~X10(); -}; - -struct X11 : X10 { // expected-error {{no suitable member 'operator delete' in 'X11'}} - void operator delete(void*, int); // expected-note {{'operator delete' declared here}} +#if __cplusplus >= 201103L + // expected-note@-2 {{overridden virtual function is here}} +#endif +}; + +struct X11 : X10 { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'X11'}} +#else +// expected-error@-4 {{deleted function '~X11' cannot override a non-deleted function}} +// expected-note@-5 2 {{virtual destructor requires an unambiguous, accessible 'operator delete'}} +#endif + void operator delete(void*, int); +#if __cplusplus <= 199711L + // expected-note@-2 {{'operator delete' declared here}} +#endif }; void f() { - X11 x11; // expected-note {{implicit destructor for 'X11' first required here}} + X11 x11; +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit destructor for 'X11' first required here}} +#else + // expected-error@-4 {{attempt to use a deleted function}} +#endif } struct X12 { @@ -398,10 +437,24 @@ } namespace ArrayNewNeedsDtor { - struct A { A(); private: ~A(); }; // expected-note {{declared private here}} - struct B { B(); A a; }; // expected-error {{field of type 'ArrayNewNeedsDtor::A' has private destructor}} + struct A { A(); private: ~A(); }; +#if __cplusplus <= 199711L + // expected-note@-2 {{declared private here}} +#endif + struct B { B(); A a; }; +#if __cplusplus <= 199711L + // expected-error@-2 {{field of type 'ArrayNewNeedsDtor::A' has private destructor}} +#else + // expected-note@-4 {{destructor of 'B' is implicitly deleted because field 'a' has an inaccessible destructor}} +#endif + B *test9() { - return new B[5]; // expected-note {{implicit destructor for 'ArrayNewNeedsDtor::B' first required here}} + return new B[5]; +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit destructor for 'ArrayNewNeedsDtor::B' first required here}} +#else + // expected-error@-4 {{attempt to use a deleted function}} +#endif } } Index: test/SemaCXX/no-wchar.cpp =================================================================== --- test/SemaCXX/no-wchar.cpp +++ test/SemaCXX/no-wchar.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify %s +// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify -std=c++98 %s +// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify -std=c++11 %s wchar_t x; // expected-error {{unknown type name 'wchar_t'}} typedef unsigned short wchar_t; @@ -9,7 +11,11 @@ } void foo1(wchar_t * t = L""); -// expected-warning@-1 {{conversion from string literal to 'wchar_t *' (aka 'unsigned short *') is deprecated}} +#if __cplusplus <= 199711L +// expected-warning@-2 {{conversion from string literal to 'wchar_t *' (aka 'unsigned short *') is deprecated}} +#else +// expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'wchar_t *' (aka 'unsigned short *')}} +#endif short *a = L""; // expected-error@-1 {{cannot initialize a variable of type 'short *' with an lvalue of type 'const unsigned short [1]'}} Index: test/SemaCXX/virtual-member-functions-key-function.cpp =================================================================== --- test/SemaCXX/virtual-member-functions-key-function.cpp +++ test/SemaCXX/virtual-member-functions-key-function.cpp @@ -1,20 +1,51 @@ // 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 A { virtual ~A(); +#if __cplusplus >= 201103L +// expected-note@-2 2 {{overridden virtual function is here}} +#endif }; -struct B : A { // expected-error {{no suitable member 'operator delete' in 'B'}} - B() { } // expected-note {{implicit destructor for 'B' first required here}} - void operator delete(void *, int); // expected-note {{'operator delete' declared here}} +struct B : A { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'B'}} +#else +// expected-error@-4 {{deleted function '~B' cannot override a non-deleted function}} +// expected-note@-5 {{virtual destructor requires an unambiguous, accessible 'operator delete'}} +#endif + B() { } +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'B' first required here}} +#endif + + void operator delete(void *, int); +#if __cplusplus <= 199711L +// expected-note@-2 {{'operator delete' declared here}} +#endif }; -struct C : A { // expected-error {{no suitable member 'operator delete' in 'C'}} - void operator delete(void *, int); // expected-note {{'operator delete' declared here}} +struct C : A { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'C'}} +#else +// expected-error@-4 {{deleted function '~C' cannot override a non-deleted function}} +// expected-note@-5 {{virtual destructor requires an unambiguous, accessible 'operator delete'}} +#endif + void operator delete(void *, int); +#if __cplusplus <= 199711L +// expected-note@-2 {{'operator delete' declared here}} +#endif }; void f() { (void)new B; - (void)new C; // expected-note {{implicit destructor for 'C' first required here}} + (void)new C; +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'C' first required here}} +#endif } // Make sure that the key-function computation is consistent when the Index: test/SemaCXX/warn-bool-conversion.cpp =================================================================== --- test/SemaCXX/warn-bool-conversion.cpp +++ test/SemaCXX/warn-bool-conversion.cpp @@ -1,19 +1,66 @@ // 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 BooleanFalse { -int* j = false; // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} - -void foo(int* i, int *j=(false)) // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} +int* j = false; +#if __cplusplus <= 199711L +// expected-warning@-2 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@-4 {{cannot initialize a variable of type 'int *' with an rvalue of type 'bool'}} +#endif + +#if __cplusplus <= 199711L +// expected-warning@+6 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@+4 {{cannot initialize a parameter of type 'int *' with an rvalue of type 'bool'}} +// expected-note@+3 {{passing argument to parameter 'j' here}} +// expected-note@+2 6 {{candidate function not viable: requires 2 arguments, but 1 was provided}} +#endif +void foo(int* i, int *j=(false)) { - foo(false); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} - foo((int*)false); // no-warning: explicit cast - foo(0); // no-warning: not a bool, even though its convertible to bool - - foo(false == true); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} - foo((42 + 24) < 32); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} + foo(false); +#if __cplusplus <= 199711L +// expected-warning@-2 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif + + foo((int*)false); +#if __cplusplus <= 199711L +// no-warning: explicit cast +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif + + foo(0); +#if __cplusplus <= 199711L +// no-warning: not a bool, even though its convertible to bool +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif + + foo(false == true); +#if __cplusplus <= 199711L +// expected-warning@-2 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif + + foo((42 + 24) < 32); +#if __cplusplus <= 199711L +// expected-warning@-2 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif const bool kFlag = false; - foo(kFlag); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} + foo(kFlag); +#if __cplusplus <= 199711L +// expected-warning@-2 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif } char f(struct Undefined*); Index: test/SemaCXX/zero-length-arrays.cpp =================================================================== --- test/SemaCXX/zero-length-arrays.cpp +++ test/SemaCXX/zero-length-arrays.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // class Foo { @@ -12,6 +13,9 @@ class Bar { int foo_count; Foo foos[0]; +#if __cplusplus >= 201103L +// expected-note@-2 {{copy constructor of 'Bar' is implicitly deleted because field 'foos' has an inaccessible copy constructor}} +#endif Foo foos2[0][2]; Foo foos3[2][0]; @@ -23,5 +27,10 @@ void testBar() { Bar b; Bar b2(b); +#if __cplusplus >= 201103L +// expected-error@-2 {{call to implicitly-deleted copy constructor of 'Bar}} +#else +// expected-no-diagnostics +#endif b = b2; } Index: test/SemaTemplate/instantiate-c99.cpp =================================================================== --- test/SemaTemplate/instantiate-c99.cpp +++ test/SemaTemplate/instantiate-c99.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 // Test template instantiation for C99-specific features. @@ -9,8 +11,13 @@ struct DesigInit0 { void f(XType x, YType y) { T agg = { +#if __cplusplus <= 199711L .y = y, // expected-error{{does not refer}} .x = x // expected-error{{does not refer}} +#else + .y = static_cast(y), // expected-error{{does not refer}} + .x = static_cast(x) // expected-error{{does not refer}} +#endif }; } }; @@ -44,7 +51,11 @@ struct DesigArrayInit0 { void f(Val1 val1, Val2 val2) { T array = { +#if __cplusplus <= 199711L [Subscript1] = val1, +#else + [Subscript1] = static_cast(val1), +#endif [Subscript2] = val2 // expected-error{{exceeds array bounds}} }; @@ -60,7 +71,11 @@ struct DesigArrayRangeInit0 { void f(Val1 val1) { T array = { +#if __cplusplus <= 199711L [Subscript1...Subscript2] = val1 // expected-error{{exceeds}} +#else + [Subscript1...Subscript2] = static_cast(val1) // expected-error{{exceeds}} +#endif }; } }; @@ -74,7 +89,11 @@ template struct CompoundLiteral0 { T f(Arg1 a1, Arg2 a2) { +#if __cplusplus <= 199711L return (T){a1, a2}; +#else + return (T){static_cast(a1), a2}; +#endif } }; Index: test/SemaTemplate/temp_explicit.cpp =================================================================== --- test/SemaTemplate/temp_explicit.cpp +++ test/SemaTemplate/temp_explicit.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s // // Tests explicit instantiation of templates. template class X0 { }; @@ -98,7 +100,12 @@ template struct X5::Inner2; // expected-note{{instantiation}} namespace N3 { - template struct N2::X5::Inner2; // expected-warning {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}} + template struct N2::X5::Inner2; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}} +#else +// expected-error@-4 {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}} +#endif } struct X6 { @@ -145,7 +152,17 @@ namespace N2 { using namespace N1; - template struct X7; // expected-warning{{must occur in namespace}} - - template struct X9; // expected-warning{{must occur at global scope}} + template struct X7; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'N1::X7' must occur in namespace 'N1'}} +#else +// expected-error@-4 {{explicit instantiation of 'N1::X7' must occur in namespace 'N1'}} +#endif + + template struct X9; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'X9' must occur at global scope}} +#else +// expected-error@-4 {{explicit instantiation of 'X9' must occur at global scope}} +#endif } Index: test/SemaTemplate/value-dependent-null-pointer-constant.cpp =================================================================== --- test/SemaTemplate/value-dependent-null-pointer-constant.cpp +++ test/SemaTemplate/value-dependent-null-pointer-constant.cpp @@ -1,17 +1,30 @@ -// RUN: %clang_cc1 -fsyntax-only %s +// 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 X0 { const char *f0(bool Cond) { return Cond? "honk" : N; +#if __cplusplus >= 201103L +// expected-error@-2 {{incompatible operand types ('const char *' and 'int')}} +#else +// expected-no-diagnostics +#endif } const char *f1(bool Cond) { return Cond? N : "honk"; +#if __cplusplus >= 201103L +// expected-error@-2 {{incompatible operand types ('int' and 'const char *')}} +#endif } bool f2(const char *str) { return str == N; +#if __cplusplus >= 201103L +// expected-error@-2 {{comparison between pointer and integer ('const char *' and 'int')}} +#endif } }; Index: test/SemaTemplate/virtual-member-functions.cpp =================================================================== --- test/SemaTemplate/virtual-member-functions.cpp +++ test/SemaTemplate/virtual-member-functions.cpp @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++11 %s // RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -std=c++98 -verify %s +// RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -std=c++11 -verify %s namespace PR5557 { template struct A { @@ -76,34 +80,76 @@ } namespace PR7114 { - class A { virtual ~A(); }; // expected-note{{declared private here}} + class A { virtual ~A(); }; +#if __cplusplus <= 199711L + // expected-note@-2{{declared private here}} +#else + // expected-note@-4 3 {{overridden virtual function is here}} +#endif template class B { public: - class Inner : public A { }; // expected-error{{base class 'PR7114::A' has private destructor}} + class Inner : public A { }; +#if __cplusplus <= 199711L +// expected-error@-2{{base class 'PR7114::A' has private destructor}} +#else +// expected-error@-4 2 {{deleted function '~Inner' cannot override a non-deleted function}} +// expected-note@-5 2 {{destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}} +#ifdef MSABI +// expected-note@-7 1 {{destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}} +#endif +#endif + static Inner i; static const unsigned value = sizeof(i) == 4; +#if __cplusplus >= 201103L +// expected-note@-2 {{in instantiation of member class 'PR7114::B::Inner' requested here}} +// expected-note@-3 {{in instantiation of member class 'PR7114::B::Inner' requested here}} +#endif }; int f() { return B::value; } +#if __cplusplus >= 201103L +// expected-note@-2 {{in instantiation of template class 'PR7114::B' requested here}} +#endif #ifdef MSABI - void test_typeid(B::Inner bfi) { // expected-note{{implicit destructor}} + void test_typeid(B::Inner bfi) { +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor}} +#else +// expected-error@-4 {{attempt to use a deleted function}} +// expected-note@-5 {{in instantiation of template class 'PR7114::B' requested here}} +#endif + (void)typeid(bfi); #else void test_typeid(B::Inner bfi) { - (void)typeid(bfi); // expected-note{{implicit destructor}} +#if __cplusplus >= 201103L +// expected-note@-2 {{in instantiation of template class 'PR7114::B' requested here}} +#endif + (void)typeid(bfi); +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor}} +#endif #endif } template struct X : A { +#if __cplusplus >= 201103L +// expected-error@-2 {{deleted function '~X' cannot override a non-deleted function}} +// expected-note@-3 {{destructor of 'X' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}} +#endif void f() { } }; void test_X(X &xi, X &xf) { xi.f(); +#if __cplusplus >= 201103L +// expected-note@-2 {{in instantiation of template class 'PR7114::X' requested here}} +#endif } }