diff --git a/clang/test/AST/ast-dump-openmp-begin-declare-variant_11.c b/clang/test/AST/ast-dump-openmp-begin-declare-variant_11.c --- a/clang/test/AST/ast-dump-openmp-begin-declare-variant_11.c +++ b/clang/test/AST/ast-dump-openmp-begin-declare-variant_11.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify=c_mode -ast-dump %s | FileCheck %s --check-prefix=C -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify=cxx_mode -ast-dump %s -x c++| FileCheck %s --check-prefix=CXX - +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify=cxx_mode -ast-dump %s -x c++ %std_cxx11-14 | FileCheck %s --check-prefix=CXX +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify=cxx_mode,cxx17 -ast-dump %s -x c++ %std_cxx17- | FileCheck %s --check-prefix=CXX // c_mode-no-diagnostics #ifdef __cplusplus @@ -16,10 +16,10 @@ static int also_after2(void) { return 0; } -__attribute__((nothrow)) int also_after3(void) { +__attribute__((nothrow)) int also_after3(void) { // cxx17-note {{previous declaration is here}} return 0; } -static CONST __attribute__((nothrow, always_inline)) __inline__ int also_after4(void) { // cxx_mode-note {{previous declaration is here}} +static CONST __attribute__((nothrow, always_inline)) __inline__ int also_after4(void) { // cxx_mode-note {{previous declaration is here}} cxx17-note {{previous declaration is here}} return 0; } #pragma omp end declare variant @@ -30,10 +30,10 @@ int also_after2(void) { return 2; } -int also_after3(void) { +int also_after3(void) { // cxx17-warning {{'also_after3' is missing exception specification '__attribute__((nothrow))'}} return 3; } -int also_after4(void) { // cxx_mode-error {{non-constexpr declaration of 'also_after4' follows constexpr declaration}} +int also_after4(void) { // cxx_mode-error {{non-constexpr declaration of 'also_after4' follows constexpr declaration}} cxx17-warning {{'also_after4' is missing exception specification '__attribute__((nothrow))'}} return 4; } diff --git a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp --- a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp +++ b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++| FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s %std_cxx11-14 | FileCheck %s --check-prefixes=CHECK,CXX11 +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s %std_cxx17- | FileCheck %s --check-prefixes=CHECK,CXX17 // expected-no-diagnostics // PR47655 - template struct S { S(int, T *) {} }; @@ -53,7 +53,7 @@ // CHECK-NEXT: | | | |-MoveConstructor exists simple trivial needs_implicit // CHECK-NEXT: | | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param // CHECK-NEXT: | | | |-MoveAssignment exists simple trivial needs_implicit -// CHECK-NEXT: | | | `-Destructor simple irrelevant trivial needs_implicit +// CHECK-NEXT: | | | `-Destructor simple irrelevant trivial {{(constexpr )?}}needs_implicit // CHECK-NEXT: | | |-CXXRecordDecl [[ADDR_3:0x[a-z0-9]*]] col:30 implicit referenced struct S // CHECK-NEXT: | | `-CXXConstructorDecl [[ADDR_4:0x[a-z0-9]*]] col:3 S 'void (int, T *)' // CHECK-NEXT: | | |-ParmVarDecl [[ADDR_5:0x[a-z0-9]*]] col:8 'int' @@ -76,10 +76,12 @@ // CHECK-NEXT: | | | `-CompoundStmt [[ADDR_7]] // CHECK-NEXT: | | |-CXXConstructorDecl [[ADDR_14:0x[a-z0-9]*]] col:30 implicit constexpr S 'void (const S &)' inline default trivial noexcept-unevaluated [[ADDR_14]] // CHECK-NEXT: | | | `-ParmVarDecl [[ADDR_15:0x[a-z0-9]*]] col:30 'const S &' -// CHECK-NEXT: | | |-CXXConstructorDecl [[ADDR_16:0x[a-z0-9]*]] col:30 implicit used constexpr S 'void (S &&) noexcept' inline default trivial -// CHECK-NEXT: | | | |-ParmVarDecl [[ADDR_17:0x[a-z0-9]*]] col:30 'S &&' -// CHECK-NEXT: | | | `-CompoundStmt [[ADDR_18:0x[a-z0-9]*]] -// CHECK-NEXT: | | `-CXXDestructorDecl [[ADDR_19:0x[a-z0-9]*]] col:30 implicit referenced ~S 'void ({{.*}}) noexcept' inline default trivial +// CXX11-NEXT: | | |-CXXConstructorDecl [[ADDR_16:0x[a-z0-9]*]] col:30 implicit used constexpr S 'void (S &&) noexcept' inline default trivial +// CXX11-NEXT: | | | |-ParmVarDecl [[ADDR_17:0x[a-z0-9]*]] col:30 'S &&' +// CXX11-NEXT: | | | `-CompoundStmt [[ADDR_18:0x[a-z0-9]*]] +// CXX17-NEXT: | | |-CXXConstructorDecl [[ADDR_16:0x[a-z0-9]*]] col:30 implicit constexpr S 'void (S &&)' inline default trivial noexcept-unevaluated +// CXX17-NEXT: | | | `-ParmVarDecl [[ADDR_17:0x[a-z0-9]*]] col:30 'S &&' +// CHECK-NEXT: | | `-CXXDestructorDecl [[ADDR_19:0x[a-z0-9]*]] col:30 implicit referenced {{(constexpr )?}}~S 'void ({{.*}}) noexcept' inline default trivial // CHECK-NEXT: | `-ClassTemplateSpecializationDecl [[ADDR_20:0x[a-z0-9]*]] line:5:30 struct S // CHECK-NEXT: | `-TemplateArgument type 'double' // CHECK-NEXT: | `-BuiltinType [[ADDR_21:0x[a-z0-9]*]] 'double' @@ -216,7 +218,7 @@ // CHECK-NEXT: `-FunctionDecl [[ADDR_126:0x[a-z0-9]*]] line:42:5 test 'int ({{.*}})' // CHECK-NEXT: `-CompoundStmt [[ADDR_127:0x[a-z0-9]*]] // CHECK-NEXT: `-ReturnStmt [[ADDR_128:0x[a-z0-9]*]] -// CHECK-NEXT: `-ExprWithCleanups [[ADDR_129:0x[a-z0-9]*]] 'int' +// CXX11-NEXT: `-ExprWithCleanups [[ADDR_129:0x[a-z0-9]*]] 'int' // CHECK-NEXT: `-BinaryOperator [[ADDR_130:0x[a-z0-9]*]] 'int' '+' // CHECK-NEXT: |-BinaryOperator [[ADDR_131:0x[a-z0-9]*]] 'int' '+' // CHECK-NEXT: | |-BinaryOperator [[ADDR_132:0x[a-z0-9]*]] 'int' '+' @@ -241,8 +243,8 @@ // CHECK-NEXT: |-CallExpr [[ADDR_151:0x[a-z0-9]*]] 'int' // CHECK-NEXT: | |-ImplicitCastExpr [[ADDR_152:0x[a-z0-9]*]] 'int (*)(S)' // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_153:0x[a-z0-9]*]] 'int (S)' {{.*}}Function [[ADDR_65]] 'special' 'int (S)' (FunctionTemplate [[ADDR_58]] 'special') -// CHECK-NEXT: | `-CXXConstructExpr [[ADDR_154:0x[a-z0-9]*]] 'S':'S' 'void (S &&) noexcept' elidable -// CHECK-NEXT: | `-MaterializeTemporaryExpr [[ADDR_155:0x[a-z0-9]*]] 'S':'S' xvalue +// CXX11-NEXT: | `-CXXConstructExpr [[ADDR_154:0x[a-z0-9]*]] 'S':'S' 'void (S &&) noexcept' elidable +// CXX11-NEXT: | `-MaterializeTemporaryExpr [[ADDR_155:0x[a-z0-9]*]] 'S':'S' xvalue // CHECK-NEXT: | `-CXXTemporaryObjectExpr [[ADDR_156:0x[a-z0-9]*]] 'S':'S' 'void (int, int *)' // CHECK-NEXT: | |-IntegerLiteral [[ADDR_157:0x[a-z0-9]*]] 'int' 0 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_158:0x[a-z0-9]*]] 'int *' @@ -250,9 +252,10 @@ // CHECK-NEXT: `-CallExpr [[ADDR_160:0x[a-z0-9]*]] 'int' // CHECK-NEXT: |-ImplicitCastExpr [[ADDR_161:0x[a-z0-9]*]] 'int (*)(S)' // CHECK-NEXT: | `-DeclRefExpr [[ADDR_68]] 'int (S)' {{.*}}Function [[ADDR_69]] 'special[implementation={extension(allow_templates)}]' 'int (S)' -// CHECK-NEXT: `-CXXConstructExpr [[ADDR_162:0x[a-z0-9]*]] 'S':'S' 'void (S &&) noexcept' elidable -// CHECK-NEXT: `-MaterializeTemporaryExpr [[ADDR_163:0x[a-z0-9]*]] 'S':'S' xvalue -// CHECK-NEXT: `-CXXTemporaryObjectExpr [[ADDR_156]] 'S':'S' 'void (int, int *)' +// CXX11-NEXT: `-CXXConstructExpr [[ADDR_162:0x[a-z0-9]*]] 'S':'S' 'void (S &&) noexcept' elidable +// CXX11-NEXT: `-MaterializeTemporaryExpr [[ADDR_163:0x[a-z0-9]*]] 'S':'S' xvalue +// CXX11-NEXT: `-CXXTemporaryObjectExpr [[ADDR_156]] 'S':'S' 'void (int, int *)' +// CXX17-NEXT: `-CXXTemporaryObjectExpr [[ADDR_156]] 'S':'S' 'void (int, int *)' // CHECK-NEXT: |-IntegerLiteral [[ADDR_157]] 'int' 0 // CHECK-NEXT: `-ImplicitCastExpr [[ADDR_158]] 'int *' // CHECK-NEXT: `-IntegerLiteral [[ADDR_159]] 'int' 0 diff --git a/clang/test/AST/ast-dump-undeduced-expr.cpp b/clang/test/AST/ast-dump-undeduced-expr.cpp --- a/clang/test/AST/ast-dump-undeduced-expr.cpp +++ b/clang/test/AST/ast-dump-undeduced-expr.cpp @@ -4,4 +4,4 @@ static constexpr auto Bar = ; }; -// CHECK: -VarDecl {{.*}} invalid Bar 'const auto' static constexpr +// CHECK: -VarDecl {{.*}} invalid Bar 'const auto' static {{(inline )?}}constexpr diff --git a/clang/test/AST/sourceranges.cpp b/clang/test/AST/sourceranges.cpp --- a/clang/test/AST/sourceranges.cpp +++ b/clang/test/AST/sourceranges.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i686-mingw32 -ast-dump %s | FileCheck %s -// RUN: %clang_cc1 -triple i686-mingw32 -std=c++1z -ast-dump %s | FileCheck %s -check-prefix=CHECK-1Z +// RUN: %clang_cc1 -triple i686-mingw32 %std_cxx11-14 -ast-dump %s | FileCheck %s +// RUN: %clang_cc1 -triple i686-mingw32 %std_cxx17- -ast-dump %s | FileCheck %s -check-prefix=CHECK-1Z template class P { diff --git a/clang/test/Analysis/blocks.m b/clang/test/Analysis/blocks.m --- a/clang/test/Analysis/blocks.m +++ b/clang/test/Analysis/blocks.m @@ -14,6 +14,9 @@ __attribute__((visibility("default"))) __attribute__((__malloc__)) __attribute__((__warn_unused_result__)) __attribute__((__nothrow__)) dispatch_queue_t dispatch_queue_create(const char *label, dispatch_queue_attr_t attr); typedef long dispatch_once_t; void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block); +#if __cplusplus >= 201703L +__attribute__((__nothrow__)) +#endif dispatch_queue_t dispatch_queue_create(const char *label, dispatch_queue_attr_t attr); diff --git a/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp b/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp --- a/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp +++ b/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp @@ -1,5 +1,5 @@ // FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg. -// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \ +// RUN: %clang_cc1 -std=c++14 -analyze -triple x86_64-unknown-linux-gnu \ // RUN: -analyze-function "test()" \ // RUN: -analyzer-checker=core \ // RUN: -analyzer-dump-egraph=%t.dot %s diff --git a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp --- a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp +++ b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp @@ -1,6 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -Wno-dynamic-exception-spec %std_cxx98- %s int *use_new(int N) { if (N == 1) return new int; @@ -25,6 +23,7 @@ #if __cplusplus < 201103L // expected-note@-2 {{previous declaration}} #endif + void* operator new[](std::size_t) throw(std::bad_alloc); void operator delete(void*) throw(); // expected-note{{previous declaration}} void operator delete[](void*) throw(); diff --git a/clang/test/CXX/class.access/class.friend/p1.cpp b/clang/test/CXX/class.access/class.friend/p1.cpp --- a/clang/test/CXX/class.access/class.friend/p1.cpp +++ b/clang/test/CXX/class.access/class.friend/p1.cpp @@ -221,13 +221,21 @@ #if __cplusplus >= 201103L constexpr #endif - A::A(); + A::A() +#if __cplusplus >= 201703L + noexcept +#endif + ; friend A::~A(); friend #if __cplusplus >= 201402L constexpr #endif - A &A::operator=(const A&); + A &A::operator=(const A&) +#if __cplusplus >= 201703L + noexcept +#endif + ; }; } @@ -246,7 +254,11 @@ #if __cplusplus >= 201103L constexpr #endif - X::X(const X&); + X::X(const X&) +#if __cplusplus >= 201703L + noexcept +#endif + ; private: A(); // expected-note 2 {{declared private here}} diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp @@ -16,8 +16,10 @@ #endif register int ro; // expected-error {{illegal storage class on file-scoped variable}} -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'register' storage class specifier is deprecated}} +#if __cplusplus >= 201703L +// expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}} +#elif __cplusplus >= 201103L +// expected-warning@-4 {{'register' storage class specifier is deprecated}} #endif register void rf(); // expected-error {{illegal storage class on function}} @@ -37,9 +39,12 @@ }; void foo(auto int ap, register int rp) { -#if __cplusplus >= 201103L // C++11 or later +#if __cplusplus >= 201703L // expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} -// expected-warning@-3 {{'register' storage class specifier is deprecated}} +// expected-error@-3 {{ISO C++17 does not allow 'register' storage class specifier}} +#elif __cplusplus >= 201103L +// expected-warning@-5 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} +// expected-warning@-6 {{'register' storage class specifier is deprecated}} #endif auto int abo; #if __cplusplus >= 201103L // C++11 or later @@ -51,8 +56,10 @@ #endif register int rbo; -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'register' storage class specifier is deprecated}} +#if __cplusplus >= 201703L +// expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}} +#elif __cplusplus >= 201103L +// expected-warning@-4 {{'register' storage class specifier is deprecated}} #endif register void rbf(); // expected-error {{illegal storage class on function}} diff --git a/clang/test/CXX/except/except.spec/p2-dynamic-types.cpp b/clang/test/CXX/except/except.spec/p2-dynamic-types.cpp --- a/clang/test/CXX/except/except.spec/p2-dynamic-types.cpp +++ b/clang/test/CXX/except/except.spec/p2-dynamic-types.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s +// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fsyntax-only -Wno-dynamic-exception-spec -verify %s // Dynamic specifications: valid types. diff --git a/clang/test/CXX/except/except.spec/p9-dynamic.cpp b/clang/test/CXX/except/except.spec/p9-dynamic.cpp --- a/clang/test/CXX/except/except.spec/p9-dynamic.cpp +++ b/clang/test/CXX/except/except.spec/p9-dynamic.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -no-opaque-pointers %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s --check-prefixes=CHECK,CHECK-PRE17 -// RUN: %clang_cc1 -no-opaque-pointers %s -triple=x86_64-apple-darwin10 -std=c++17 -Wno-dynamic-exception-spec -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s --check-prefixes=CHECK,CHECK-17 +// RUN: %clang_cc1 %std_cxx98-14 -no-opaque-pointers %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s --check-prefixes=CHECK,CHECK-PRE17 +// RUN: %clang_cc1 %std_cxx17- -no-opaque-pointers %s -triple=x86_64-apple-darwin10 -Wno-dynamic-exception-spec -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s --check-prefixes=CHECK,CHECK-17 void external(); diff --git a/clang/test/CXX/stmt.stmt/stmt.select/p3.cpp b/clang/test/CXX/stmt.stmt/stmt.select/p3.cpp --- a/clang/test/CXX/stmt.stmt/stmt.select/p3.cpp +++ b/clang/test/CXX/stmt.stmt/stmt.select/p3.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s -// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -std=c++1z -Wc++14-compat -verify %s -DCPP17 +// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %std_cxx98-14 %s +// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -Wc++14-compat -verify %std_cxx17- %s -DCPP17 int f(); 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 --- 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,6 +1,5 @@ -// 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 -fsyntax-only -verify=expected,precxx17 -triple=x86_64-linux-gnu %std_cxx98-14 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17 -triple=x86_64-linux-gnu %std_cxx17- %s // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -triple=x86_64-linux-gnu %s -DCPP11ONLY // C++11 [temp.arg.nontype]p1: @@ -32,19 +31,19 @@ // omitted if the name refers to a function or array and shall be omitted // if the corresopnding template-parameter is a reference; or namespace addr_of_obj_or_func { - template struct X0 { }; // expected-note 5{{here}} + template struct X0 { }; // precxx17-note 5{{here}} #if __cplusplus >= 201103L - // expected-note@-2 2{{template parameter is declared here}} + // precxx17-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}} + template struct X2 { }; // precxx17-note 4{{here}} + template struct X2k { }; // precxx17-note {{here}} + template struct X3 { }; // precxx17-note 4{{here}} int i = 42; #if __cplusplus >= 201103L - // expected-note@-2 {{declared here}} + // precxx17-note@-2 {{declared here}} #endif int iarr[10]; @@ -54,9 +53,9 @@ // expected-note@-2 5{{non-type template argument refers to object here}} #endif - __thread int ti = 100; // expected-note {{here}} + __thread int ti = 100; // precxx17-note {{here}} #if __cplusplus <= 199711L - // expected-note@-2 {{here}} + // precxx17-note@-2 {{here}} #endif static int f_internal(int); @@ -72,18 +71,19 @@ #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}} + // precxx17-error@-4 {{non-type template argument of type 'int' is not a constant expression}} + // precxx17-note@-5 {{read of non-const variable 'i' is not allowed in a constant expression}} + // cxx17-error@-6 {{value of type 'int' is not implicitly convertible to 'int *'}} #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}} + X0<&iarr> x0b_addr; // precxx17-error {{cannot be converted to a value of type 'int *'}} cxx17-error {{value of type 'int (*)[10]' is not implicitly convertible to 'int *'}} + X0 x0c; // precxx17-error {{must have its address taken}} cxx17-error {{value of type 'const int' is not implicitly convertible to 'int *'}} #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 *'}} + X0<&ki> x0c_addr; // precxx17-error {{cannot be converted to a value of type 'int *'}} cxx17-error {{value of type 'const int *' is not implicitly convertible to 'int *'}} #if __cplusplus <= 199711L // expected-warning@-2 {{internal linkage is a C++11 extension}} #endif @@ -92,7 +92,8 @@ #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}} + // precxx17-error@-4 {{non-type template argument of type 'int *' is not a constant expression}} + // cxx17-error@-5 {{on-type template argument is not a constant expression}} #endif X1 x1a; @@ -112,10 +113,10 @@ #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}} + X2<&i> x2a_addr; // precxx17-error {{address taken}} cxx17-error {{value of type 'int *' is not implicitly convertible to 'int &'}} + X2 x2b; // precxx17-error {{cannot bind to template argument of type 'int[10]'}} cxx17-error {{value of type 'int[10]' is not implicitly convertible to 'int &'}} + X2<&iarr> x2b_addr; // precxx17-error {{address taken}} cxx17-error {{value of type 'int (*)[10]' is not implicitly convertible to 'int &'}} + X2 x2c; // precxx17-error {{ignores qualifiers}} cxx17-error {{value of type 'const int' is not implicitly convertible to 'int &'}} #if __cplusplus <= 199711L // expected-warning@-2 {{internal linkage is a C++11 extension}} #endif @@ -125,24 +126,24 @@ // expected-warning@-2 {{internal linkage is a C++11 extension}} #endif - X2k<&ki> x2kc_addr; // expected-error {{address taken}} + X2k<&ki> x2kc_addr; // precxx17-error {{address taken}} cxx17-error {{value of type 'const int *' is not implicitly convertible to 'const int &'}} #if __cplusplus <= 199711L // expected-warning@-2 {{internal linkage is a C++11 extension}} #endif - X2 x2d_addr; // expected-error {{refers to thread-local object}} + X2 x2d_addr; // precxx17-error {{refers to thread-local object}} cxx17-error {{non-type template argument is not a constant expression}} X3 x3a; - X3<&f> x3a_addr; // expected-error {{address taken}} + X3<&f> x3a_addr; // precxx17-error {{address taken}} cxx17-error {{value of type 'int (*)(int)' is not implicitly convertible to 'int (&)(int)'}} X3 x3b; - X3<&f_tmpl> x3b_addr; // expected-error {{address taken}} + X3<&f_tmpl> x3b_addr; // precxx17-error {{address taken}} cxx17-error {{value of type '' is not implicitly convertible to 'int (&)(int)'}} X3 > x3c; - X3<&f_tmpl > x3c_addr; // expected-error {{address taken}} + X3<&f_tmpl > x3c_addr; // precxx17-error {{address taken}} cxx17-error {{value of type '' is not implicitly convertible to 'int (&)(int)'}} 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}} + X3<&f_internal> x3d_addr; // precxx17-error {{address taken}} cxx17-error {{value of type 'int (*)(int)' is not implicitly convertible to 'int (&)(int)'}} #if __cplusplus <= 199711L // expected-warning@-2 {{internal linkage is a C++11 extension}} #endif @@ -158,13 +159,14 @@ #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}} + // precxx17-error@-4 {{non-type template argument of type 'int *' is not a constant expression}} + // cxx17-error@-5 {{non-type template argument is not a constant expression}} + // expected-note@-6 {{pointer to 'n' is not a constant expression}} #endif - 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}} + struct Local { static int f() {} }; // precxx17-note {{here}} + X1<&Local::f> x1_no_linkage; // precxx17-error {{non-type template argument refers to function 'f' that does not have linkage}} cxx17-error {{value of type 'int (*)()' is not implicitly convertible to 'int (*)(int)'}} + X0<&S::NonStaticMember> x0_non_static; // precxx17-error {{non-static data member}} cxx17-error {{value of type 'int addr_of_obj_or_func::S::*' is not implicitly convertible to 'int *'}} } } @@ -174,9 +176,11 @@ // -- a pointer to member expressed as described in 5.3.1. namespace bad_args { - template struct X0 { }; // expected-note 2{{template parameter is declared here}} + template struct X0 { }; // precxx17-note 2{{template parameter is declared here}} int i = 42; - X0<&i + 2> x0a; // expected-error{{non-type template argument does not refer to any declaration}} + X0<&i + 2> x0a; // precxx17-error{{non-type template argument does not refer to any declaration}} \ + cxx17-error {{non-type template argument is not a constant expression}} \ + cxx17-note {{cannot refer to element 2 of non-array object in a constant expression}} int* iptr = &i; #if __cplusplus >= 201103L // expected-note@-2 {{declared here}} @@ -186,8 +190,9 @@ #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}} + // precxx17-error@-4 {{non-type template argument of type 'int *' is not a constant expression}} + // cxx17-error@-5 {{non-type template argument is not a constant expression}} + // expected-note@-6 {{read of non-constexpr variable 'iptr' is not allowed in a constant expression}} #endif } #endif // CPP11ONLY diff --git a/clang/test/CXX/temp/temp.res/temp.local/p3.cpp b/clang/test/CXX/temp/temp.res/temp.local/p3.cpp --- a/clang/test/CXX/temp/temp.res/temp.local/p3.cpp +++ b/clang/test/CXX/temp/temp.res/temp.local/p3.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -verify=expected,precxx17 %std_cxx98-14 %s +// RUN: %clang_cc1 -verify=expected,cxx17 %std_cxx17- %s template struct Base { // expected-note@-1 2{{member type 'Base' found by ambiguous name lookup}} @@ -26,7 +27,9 @@ } // expected-error {{expected ';' after class}} WebVector(const WebVector& other) { } // expected-error{{undeclared identifier 'T'}} \ - expected-error{{a type specifier is required}} + precxx17-error{{a type specifier is required}} \ + cxx17-error{{deduction guide declaration without trailing return type}} \ + cxx17-error{{deduction guide cannot have a function definition}} template WebVector& operator=(const C& other) { } // expected-error{{undeclared identifier 'T'}} diff --git a/clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp b/clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp --- a/clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp +++ b/clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -fdata-sections -fcolor-diagnostics +// RUN: %clang_cc1 %s -fsyntax-only -verify=expected,precxx17 %std_cxx11-14 -fdata-sections -fcolor-diagnostics +// RUN: %clang_cc1 %s -fsyntax-only -verify %std_cxx17- -fdata-sections -fcolor-diagnostics // Warn for any function that // * takes a pointer or a reference to an object (including "this" pointer), @@ -214,10 +215,10 @@ TypedefAligned4 TA8b(11); // expected-warning {{passing 4-byte aligned argument to 8-byte aligned parameter 'this' of 'StructAligned8' may result in an unaligned pointer access}} TypedefAligned4 TA8c = TA8a + TA8b; // expected-warning {{passing 4-byte aligned argument to 8-byte aligned parameter 'this' of 'operator+' may result in an unaligned pointer access}} // expected-warning@-1 {{passing 4-byte aligned argument to 8-byte aligned parameter 1 of 'operator+' may result in an unaligned pointer access}} - // expected-warning@-2 {{passing 4-byte aligned argument to 8-byte aligned parameter 'this' of 'StructAligned8' may result in an unaligned pointer access}} + // precxx17-warning@-2 {{passing 4-byte aligned argument to 8-byte aligned parameter 'this' of 'StructAligned8' may result in an unaligned pointer access}} TypedefAligned4 TA8d = TA8a - &TA8b; // expected-warning {{passing 4-byte aligned argument to 8-byte aligned parameter 'this' of 'operator-' may result in an unaligned pointer access}} // expected-warning@-1 {{passing 4-byte aligned argument to 8-byte aligned parameter 1 of 'operator-' may result in an unaligned pointer access}} - // expected-warning@-2 {{passing 4-byte aligned argument to 8-byte aligned parameter 'this' of 'StructAligned8' may result in an unaligned pointer access}} + // precxx17-warning@-2 {{passing 4-byte aligned argument to 8-byte aligned parameter 'this' of 'StructAligned8' may result in an unaligned pointer access}} ++TA8d; // expected-warning {{passing 4-byte aligned argument to 8-byte aligned parameter 'this' of 'operator++' may result in an unaligned pointer access}} --TA8c; // expected-warning {{passing 4-byte aligned argument to 8-byte aligned parameter 'this' of 'operator--' may result in an unaligned pointer access}} UsingAligned4 UA8a(11); diff --git a/clang/test/CodeGenCXX/align-avx-complete-objects.cpp b/clang/test/CodeGenCXX/align-avx-complete-objects.cpp --- a/clang/test/CodeGenCXX/align-avx-complete-objects.cpp +++ b/clang/test/CodeGenCXX/align-avx-complete-objects.cpp @@ -1,10 +1,14 @@ -// RUN: %clang_cc1 -no-opaque-pointers -x c++ %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 -fmax-type-align=16 -emit-llvm -o - -Werror | FileCheck %s +// RUN: %clang_cc1 -no-opaque-pointers %std_cxx11-14 %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 -fmax-type-align=16 -emit-llvm -o - -Werror | FileCheck %s --check-prefixes=CHECK,PRE17 +// RUN: %clang_cc1 -no-opaque-pointers %std_cxx17- %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 -fmax-type-align=16 -emit-llvm -o - -Werror | FileCheck %s --check-prefixes=CHECK,CXX17 // rdar://16254558 typedef float AVX2Float __attribute__((__vector_size__(32))); -volatile float TestAlign(void) +#if __cplusplus < 202002L +volatile +#endif +float TestAlign(void) { volatile AVX2Float *p = new AVX2Float; *p = *p; @@ -13,7 +17,8 @@ } // CHECK: [[R:%.*]] = alloca <8 x float>, align 32 -// CHECK-NEXT: [[CALL:%.*]] = call noalias noundef nonnull i8* @_Znwm(i64 noundef 32) +// PRE17-NEXT: [[CALL:%.*]] = call noalias noundef nonnull i8* @_Znwm(i64 noundef 32) +// CXX17-NEXT: [[CALL:%.*]] = call noalias noundef nonnull align 32 i8* @_ZnwmSt11align_val_t(i64 noundef 32, i64 noundef 32) // CHECK-NEXT: [[ZERO:%.*]] = bitcast i8* [[CALL]] to <8 x float>* // CHECK-NEXT: store <8 x float>* [[ZERO]], <8 x float>** [[P:%.*]], align 8 // CHECK-NEXT: [[ONE:%.*]] = load <8 x float>*, <8 x float>** [[P]], align 8 @@ -33,7 +38,10 @@ typedef AVX2Float_indirect AVX2Float_use_existing_align; -volatile float TestAlign2(void) +#if __cplusplus < 202002L +volatile +#endif +float TestAlign2(void) { volatile AVX2Float_use_existing_align *p = new AVX2Float_use_existing_align; *p = *p; @@ -42,7 +50,8 @@ } // CHECK: [[R:%.*]] = alloca <8 x float>, align 32 -// CHECK-NEXT: [[CALL:%.*]] = call noalias noundef nonnull i8* @_Znwm(i64 noundef 32) +// PRE17-NEXT: [[CALL:%.*]] = call noalias noundef nonnull i8* @_Znwm(i64 noundef 32) +// CXX17-NEXT: [[CALL:%.*]] = call noalias noundef nonnull align 32 i8* @_ZnwmSt11align_val_t(i64 noundef 32, i64 noundef 32) // CHECK-NEXT: [[ZERO:%.*]] = bitcast i8* [[CALL]] to <8 x float>* // CHECK-NEXT: store <8 x float>* [[ZERO]], <8 x float>** [[P:%.*]], align 8 // CHECK-NEXT: [[ONE:%.*]] = load <8 x float>*, <8 x float>** [[P]], align 8 diff --git a/clang/test/CodeGenCXX/copy-constructor-elim-2.cpp b/clang/test/CodeGenCXX/copy-constructor-elim-2.cpp --- a/clang/test/CodeGenCXX/copy-constructor-elim-2.cpp +++ b/clang/test/CodeGenCXX/copy-constructor-elim-2.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 %std_cxx11-14 -no-opaque-pointers -no-enable-noundef-analysis -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,PRE17 +// RUN: %clang_cc1 %std_cxx17- -no-opaque-pointers -no-enable-noundef-analysis -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CXX17 struct A { int x; A(int); ~A(); }; A f() { return A(0); } @@ -6,7 +7,7 @@ // CHECK: call {{.*}} @_ZN1AC1Ei // CHECK-NEXT: ret void -// Verify that we do not elide copies when constructing a base class. +// Verify that we do not elide copies when constructing a base class before C++17. namespace no_elide_base { struct Base { Base(const Base&); @@ -24,8 +25,9 @@ // CHECK: define {{.*}} @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE(%"struct.no_elide_base::Derived"* {{[^,]*}} returned {{[^,]*}} %this, %"struct.no_elide_base::Other"* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %O) unnamed_addr Derived::Derived(const Other &O) // CHECK: call {{.*}} @_ZNK13no_elide_base5OthercvNS_4BaseEEv - // CHECK: call {{.*}} @_ZN13no_elide_base4BaseC2ERKS0_ - // CHECK: call {{.*}} @_ZN13no_elide_base4BaseD1Ev + // PRE17: call {{.*}} @_ZN13no_elide_base4BaseC2ERKS0_ + // PRE17: call {{.*}} @_ZN13no_elide_base4BaseD1Ev + // CXX17-NOT: call : Base(O) { // CHECK: ret @@ -83,14 +85,16 @@ B(int); }; void f() { - // Here, we construct via B(int) then B(A). The B(A) construction is + // Before C++17, we construct via B(int) then B(A). The B(A) construction is // elidable, but we don't have an AST representation for the case where we // must elide not only a constructor call but also some argument // conversions, so we don't elide it. // CHECK-LABEL: define{{.*}} void @_ZN25ElidableCallIsNotCopyCtor1fEv( // CHECK: call {{.*}} @_ZN25ElidableCallIsNotCopyCtor1BC1Ei( - // CHECK: call {{.*}} @_ZN25ElidableCallIsNotCopyCtor1AC1ERKS0_( - // CHECK: call {{.*}} @_ZN25ElidableCallIsNotCopyCtor1BC1ENS_1AE( + // PRE17: call {{.*}} @_ZN25ElidableCallIsNotCopyCtor1AC1ERKS0_( + // PRE17: call {{.*}} @_ZN25ElidableCallIsNotCopyCtor1BC1ENS_1AE( + // CXX17-NOT: call + // CHECK: ret B b = 0; } } diff --git a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp --- a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp +++ b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp @@ -1,24 +1,24 @@ // Test for DebugInfo for Defaulted parameters for C++ templates // Supported: -O0, standalone DI -// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple x86_64-linux-gnu %s -o - \ -// RUN: -O0 -disable-llvm-passes \ -// RUN: -debug-info-kind=standalone \ -// RUN: | FileCheck %s +// RUN: %clang_cc1 -emit-llvm %std_cxx11-14 -dwarf-version=5 -triple x86_64 %s -O0 -disable-llvm-passes -debug-info-kind=standalone -o - | FileCheck %s --check-prefixes=CHECK,PRE17 +// RUN: %clang_cc1 -emit-llvm %std_cxx17- -dwarf-version=5 -triple x86_64 %s -O0 -disable-llvm-passes -debug-info-kind=standalone -o - | FileCheck %s --check-prefixes=CHECK,CXX17 // CHECK: DILocalVariable(name: "f1", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]] // CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[F1_TYPE:[0-9]+]] // CHECK: [[F1_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]], ![[THIRD:[0-9]+]], ![[FORTH:[0-9]+]]} // CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}}) // CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, value: i32 6) -// CHECK: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, value: i8 0) +// PRE17: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, value: i8 0) +// CXX17: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, value: i1 false) // CHECK: DILocalVariable(name: "f2", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]] // CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: ![[F2_TYPE:[0-9]+]] // CHECK: [[F2_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]], ![[THIRD:[0-9]+]], ![[FORTH:[0-9]+]]} // CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}}, defaulted: true) // CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, defaulted: true, value: i32 3) -// CHECK: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, defaulted: true, value: i8 1) +// PRE17: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, defaulted: true, value: i8 1) +// CXX17: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, defaulted: true, value: i1 true) template class foo { diff --git a/clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp b/clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp --- a/clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp +++ b/clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - -debug-info-kind=standalone | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - -debug-info-kind=standalone %std_cxx98-14 | FileCheck %s --check-prefixes=CHECK,PRE17 +// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - -debug-info-kind=standalone %std_cxx17- | FileCheck %s --check-prefixes=CHECK,CXX17 namespace __pointer_type_imp { template struct __pointer_type1 {}; @@ -17,7 +18,8 @@ // Test that the bool template type parameter is emitted. // // CHECK: ![[PARAMS]] = !{!{{.*}}, !{{.*}}, ![[FALSE:[0-9]+]]} - // CHECK: ![[FALSE]] = !DITemplateValueParameter(type: !{{[0-9]+}}, value: i8 0) + // PRE17: ![[FALSE]] = !DITemplateValueParameter(type: !{{[0-9]+}}, value: i8 0) + // CXX17: ![[FALSE]] = !DITemplateValueParameter(type: !{{[0-9]+}}, value: i1 false) typedef typename __pointer_type_imp::__pointer_type1<_Tp, _Dp, false>::type type; }; template struct default_delete {}; diff --git a/clang/test/CodeGenCXX/exception-spec-decay.cpp b/clang/test/CodeGenCXX/exception-spec-decay.cpp --- a/clang/test/CodeGenCXX/exception-spec-decay.cpp +++ b/clang/test/CodeGenCXX/exception-spec-decay.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions %s -triple=i686-unknown-linux -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %std_cxx98- -fcxx-exceptions -fexceptions -Wno-dynamic-exception-spec %s -triple=i686-unknown-linux -emit-llvm -o - | FileCheck %s typedef int Array[10]; void foo() throw (Array) { diff --git a/clang/test/CodeGenCXX/exceptions-cxx-ehsc.cpp b/clang/test/CodeGenCXX/exceptions-cxx-ehsc.cpp --- a/clang/test/CodeGenCXX/exceptions-cxx-ehsc.cpp +++ b/clang/test/CodeGenCXX/exceptions-cxx-ehsc.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -fexceptions -fcxx-exceptions -fexternc-nounwind | FileCheck %s +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -fexceptions -fcxx-exceptions -fexternc-nounwind -Wno-dynamic-exception-spec %std_cxx98- | FileCheck %s namespace test1 { struct Cleanup { ~Cleanup(); }; diff --git a/clang/test/CodeGenCXX/exceptions-no-rtti.cpp b/clang/test/CodeGenCXX/exceptions-no-rtti.cpp --- a/clang/test/CodeGenCXX/exceptions-no-rtti.cpp +++ b/clang/test/CodeGenCXX/exceptions-no-rtti.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fno-rtti -fcxx-exceptions -fexceptions %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -fno-rtti -fcxx-exceptions -fexceptions -Wno-dynamic-exception-spec %s -triple=x86_64-apple-darwin10 -emit-llvm -o - %std_cxx98- | FileCheck %s // CHECK: @_ZTIN5test11AE = linkonce_odr constant // CHECK: @_ZTIN5test11BE = linkonce_odr constant diff --git a/clang/test/CodeGenCXX/global-init.cpp b/clang/test/CodeGenCXX/global-init.cpp --- a/clang/test/CodeGenCXX/global-init.cpp +++ b/clang/test/CodeGenCXX/global-init.cpp @@ -1,9 +1,10 @@ -// RUN: %clang_cc1 -no-opaque-pointers -triple=x86_64-apple-darwin10 -emit-llvm -fexceptions %s -o - |FileCheck %s -// RUN: %clang_cc1 -no-opaque-pointers -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck -check-prefix CHECK-NOEXC %s -// RUN: %clang_cc1 -no-opaque-pointers -triple=x86_64-apple-darwin10 -emit-llvm -mframe-pointer=non-leaf %s -o - \ +// RUN: %clang_cc1 %std_cxx98-14 -no-opaque-pointers -triple=x86_64-apple-darwin10 -emit-llvm -fexceptions %s -o - |FileCheck %s --check-prefixes=CHECK,PRE17 +// RUN: %clang_cc1 %std_cxx98-14 -no-opaque-pointers -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck %s --check-prefixes=CHECK-NOEXC,PRE17 +// RUN: %clang_cc1 %std_cxx98-14 -no-opaque-pointers -triple=x86_64-apple-darwin10 -emit-llvm -mframe-pointer=non-leaf %s -o - \ // RUN: | FileCheck -check-prefix CHECK-FP %s -// RUN: %clang_cc1 -no-opaque-pointers -triple=x86_64-apple-darwin10 -emit-llvm %s -o - -fno-builtin \ +// RUN: %clang_cc1 %std_cxx98-14 -no-opaque-pointers -triple=x86_64-apple-darwin10 -emit-llvm %s -o - -fno-builtin \ // RUN: | FileCheck -check-prefix CHECK-NOBUILTIN %s +// RUN: %clang_cc1 %std_cxx17- -no-opaque-pointers -triple=x86_64-apple-darwin10 -emit-llvm -fexceptions %s -o - | FileCheck %s struct A { A(); @@ -169,11 +170,11 @@ const int b3 = B().n; // CHECK-NOT: @_ZN5test7L2c1E - // CHECK: call void @llvm.memset{{.*}} @_ZN5test7L2c1E + // PRE17: call void @llvm.memset{{.*}} @_ZN5test7L2c1E // CHECK-NOT: @_ZN5test7L2c1E // CHECK: @_ZN5test7L2c2E // CHECK-NOT: @_ZN5test7L2c3E - // CHECK: @_ZN5test7L2c4E + // PRE17: @_ZN5test7L2c4E const C c1 = C(); const C c2 = static_cast(C()); const int c3 = C().n; diff --git a/clang/test/CodeGenCXX/no-exceptions.cpp b/clang/test/CodeGenCXX/no-exceptions.cpp --- a/clang/test/CodeGenCXX/no-exceptions.cpp +++ b/clang/test/CodeGenCXX/no-exceptions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %std_cxx11- -Wno-dynamic-exception-spec %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s void g(); diff --git a/clang/test/CodeGenCXX/override-bit-field-layout.cpp b/clang/test/CodeGenCXX/override-bit-field-layout.cpp --- a/clang/test/CodeGenCXX/override-bit-field-layout.cpp +++ b/clang/test/CodeGenCXX/override-bit-field-layout.cpp @@ -1,7 +1,9 @@ -// RUN: %clang_cc1 -w -triple=x86_64-pc-win32 -fms-compatibility -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-bit-field-layout.layout %s | FileCheck %s +// RUN: %clang_cc1 %std_cxx98-14 -w -triple=x86_64-pc-win32 -fms-compatibility -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-bit-field-layout.layout %s | FileCheck %s --check-prefixes=CHECK,PRE17 +// RUN: %clang_cc1 -std=c++17 -w -triple=x86_64-pc-win32 -fms-compatibility -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-bit-field-layout.layout %s | FileCheck %s --check-prefixes=CHECK,CXX17 +// RUN: %clang_cc1 %std_cxx20- -w -triple=x86_64-pc-win32 -fms-compatibility -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-bit-field-layout.layout %s | FileCheck %s --check-prefixes=CHECK,CXX20 -// CHECK: Type: struct S1 -// CHECK: FieldOffsets: [0, 11] +// PRE17: Type: struct S1 +// PRE17: FieldOffsets: [0, 11] struct S1 { short a : 3; short b : 5; @@ -14,6 +16,11 @@ short a : 3; }; +// CXX17: Type: struct S1 +// CXX17: FieldOffsets: [0, 11] +// CXX20: Type: struct S1 +// CXX20: FieldOffsets: [0, 3] + // CHECK: Type: struct S3 // CHECK: Size:32 // CHECK: FieldOffsets: [0, 1] diff --git a/clang/test/CodeGenCXX/override-layout.cpp b/clang/test/CodeGenCXX/override-layout.cpp --- a/clang/test/CodeGenCXX/override-layout.cpp +++ b/clang/test/CodeGenCXX/override-layout.cpp @@ -1,8 +1,16 @@ -// RUN: %clang_cc1 -w -fdump-record-layouts-simple %s > %t.layouts -// RUN: %clang_cc1 -w -fdump-record-layouts-simple %s > %t.before -// RUN: %clang_cc1 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after +// RUN: %clang_cc1 %std_cxx98-14 -w -fdump-record-layouts-simple %s > %t.layouts +// RUN: %clang_cc1 %std_cxx98-14 -w -fdump-record-layouts-simple %s > %t.before +// RUN: %clang_cc1 %std_cxx98-14 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after // RUN: diff -u %t.before %t.after -// RUN: FileCheck %s < %t.after +// RUN: FileCheck --check-prefixes=CHECK,PRE17 %s < %t.after + +// RUN: %clang_cc1 -std=c++17 -w -fdump-record-layouts-simple %s > %t.layouts +// RUN: %clang_cc1 -std=c++17 -w -fdump-record-layouts-simple %s > %t.before +// RUN: %clang_cc1 -std=c++17 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after +// RUN: diff -u %t.before %t.after +// RUN: FileCheck --check-prefixes=CHECK,CXX17 %s < %t.after + +// CXX17: Type: struct X6 // If not explicitly disabled, set PACKED to the packed attribute. #ifndef PACKED @@ -64,19 +72,19 @@ short r; }; -// CHECK: Type: struct X6 +// PRE17: Type: struct X6 struct __attribute__((aligned(16))) X6 { int x; int y; virtual ~X6(); }; -// CHECK: Type: struct X7 +// PRE17: Type: struct X7 struct X7 { int z; }; -// CHECK: Type: struct X8 +// PRE17: Type: struct X8 struct X8 : X6, virtual X7 { char c; }; diff --git a/clang/test/CodeGenCXX/reference-temporary-ms.cpp b/clang/test/CodeGenCXX/reference-temporary-ms.cpp --- a/clang/test/CodeGenCXX/reference-temporary-ms.cpp +++ b/clang/test/CodeGenCXX/reference-temporary-ms.cpp @@ -1,8 +1,10 @@ -// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -triple=i386-pc-win32 -fms-extensions | FileCheck %s +// RUN: %clang_cc1 %std_cxx98-14 -no-opaque-pointers -emit-llvm %s -o - -triple=i386-pc-win32 -fms-extensions | FileCheck %s --check-prefixes=CHECK,PRE17 +// RUN: %clang_cc1 %std_cxx17- -no-opaque-pointers -emit-llvm %s -o - -triple=i386-pc-win32 -fms-extensions | FileCheck %s --check-prefixes=CHECK,CXX17 const int __declspec(dllexport) &Exported = 42; // The reference temporary shouldn't be dllexport, even if the reference is. -// CHECK: @"?$RT1@Exported@@3ABHB" = internal constant i32 42 +// PRE17: @"?$RT1@Exported@@3ABHB" = internal constant i32 42 +// CXX17: @"?$RT1@Exported@@3ABHB" = internal global i32 42 // CHECK: @"?Exported@@3ABHB" = dso_local dllexport constant i32* @"?$RT1@Exported@@3ABHB" diff --git a/clang/test/CodeGenCXX/rtti-linkage.cpp b/clang/test/CodeGenCXX/rtti-linkage.cpp --- a/clang/test/CodeGenCXX/rtti-linkage.cpp +++ b/clang/test/CodeGenCXX/rtti-linkage.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -no-opaque-pointers %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-BOTH -// RUN: %clang_cc1 -no-opaque-pointers %s -I%S -triple=x86_64-apple-darwin10 -fvisibility=hidden -emit-llvm -o - | FileCheck -check-prefix=CHECK-WITH-HIDDEN -check-prefix=CHECK-BOTH %s +// RUN: %clang_cc1 %std_cxx98- -no-opaque-pointers %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -Wno-dynamic-exception-spec -o - | FileCheck %s -check-prefixes=CHECK,CHECK-BOTH +// RUN: %clang_cc1 %std_cxx98- -no-opaque-pointers %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -Wno-dynamic-exception-spec -fvisibility=hidden -o - | FileCheck %s --check-prefixes=CHECK-WITH-HIDDEN,CHECK-BOTH #include diff --git a/clang/test/Layout/ms-x86-vtordisp.cpp b/clang/test/Layout/ms-x86-vtordisp.cpp --- a/clang/test/Layout/ms-x86-vtordisp.cpp +++ b/clang/test/Layout/ms-x86-vtordisp.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -fno-rtti -fms-extensions -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>&1 \ +// RUN: %clang_cc1 -std=c++14 -fno-rtti -fms-extensions -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>&1 \ // RUN: | FileCheck %s -// RUN: %clang_cc1 -fno-rtti -fms-extensions -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>/dev/null \ +// RUN: %clang_cc1 -std=c++14 -fno-rtti -fms-extensions -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>/dev/null \ // RUN: | FileCheck %s -check-prefix CHECK-X64 extern "C" int printf(const char *fmt, ...); diff --git a/clang/test/Modules/update-exception-spec.cpp b/clang/test/Modules/update-exception-spec.cpp --- a/clang/test/Modules/update-exception-spec.cpp +++ b/clang/test/Modules/update-exception-spec.cpp @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/update-exception-spec -emit-llvm-only %s +// RUN: %clang_cc1 %std_cxx11- -fexceptions -fcxx-exceptions -Wno-dynamic-exception-spec -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/update-exception-spec -emit-llvm-only %s #include "a.h" void use(B *p); #include "c.h" diff --git a/clang/test/OpenMP/declare_mapper_messages.cpp b/clang/test/OpenMP/declare_mapper_messages.cpp --- a/clang/test/OpenMP/declare_mapper_messages.cpp +++ b/clang/test/OpenMP/declare_mapper_messages.cpp @@ -1,10 +1,5 @@ -// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 %s -// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 %s - -// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++98 %s -// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 %s +// RUN: %clang_cc1 -verify=expected,cxx17 -fopenmp -ferror-limit 100 %std_cxx17- %s +// RUN: %clang_cc1 -verify=expected,precxx17 -fopenmp-simd -ferror-limit 100 %std_cxx98-14 %s int temp; // expected-note {{'temp' declared here}} @@ -47,7 +42,8 @@ }; }; -#pragma omp declare mapper(default : N1::stack s) map(s.len) // expected-error {{use of class template 'N1::stack' requires template arguments}} +#pragma omp declare mapper(default : N1::stack s) map(s.len) // precxx17-error {{use of class template 'N1::stack' requires template arguments}} \ + cxx17-error {{use of class template 'stack' requires template arguments; argument deduction not allowed in function prototype}} #pragma omp declare mapper(id1: N1::stack s) map(s.data) #pragma omp declare mapper(default : S s) map(s.len) // expected-error {{no template named 'S'}} diff --git a/clang/test/PCH/cxx-functions.cpp b/clang/test/PCH/cxx-functions.cpp --- a/clang/test/PCH/cxx-functions.cpp +++ b/clang/test/PCH/cxx-functions.cpp @@ -1,8 +1,8 @@ // Test this without pch. -// RUN: %clang_cc1 -include %S/cxx-functions.h -fsyntax-only -verify %s +// RUN: %clang_cc1 -include %S/cxx-functions.h -fsyntax-only -verify -Wno-dynamic-exception-spec %std_cxx98- %s -// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-functions.h -// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s +// RUN: %clang_cc1 -x c++-header -Wno-dynamic-exception-spec -emit-pch -o %t %S/cxx-functions.h +// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify -Wno-dynamic-exception-spec %s // expected-no-diagnostics diff --git a/clang/test/Parser/cxx-casting.cpp b/clang/test/Parser/cxx-casting.cpp --- a/clang/test/Parser/cxx-casting.cpp +++ b/clang/test/Parser/cxx-casting.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp --- a/clang/test/Parser/cxx-class.cpp +++ b/clang/test/Parser/cxx-class.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fcxx-exceptions %s +// RUN: %clang_cc1 -std=c++14 -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 diff --git a/clang/test/Parser/cxx-template-argument.cpp b/clang/test/Parser/cxx-template-argument.cpp --- a/clang/test/Parser/cxx-template-argument.cpp +++ b/clang/test/Parser/cxx-template-argument.cpp @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify %s -fdelayed-template-parsing +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s -fdelayed-template-parsing // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -fdelayed-template-parsing // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -fdelayed-template-parsing diff --git a/clang/test/Parser/cxx-template-decl.cpp b/clang/test/Parser/cxx-template-decl.cpp --- a/clang/test/Parser/cxx-template-decl.cpp +++ b/clang/test/Parser/cxx-template-decl.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify=expected,cpp14 %s -// RUN: %clang_cc1 -fsyntax-only -verify=expected,cpp14 %s -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cpp14 -std=gnu++14 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cpp14 -std=gnu++14 %s -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING // RUN: %clang_cc1 -fsyntax-only -verify=expected,cpp17 -std=gnu++1z %s diff --git a/clang/test/Parser/cxx1z-nested-namespace-definition.cpp b/clang/test/Parser/cxx1z-nested-namespace-definition.cpp --- a/clang/test/Parser/cxx1z-nested-namespace-definition.cpp +++ b/clang/test/Parser/cxx1z-nested-namespace-definition.cpp @@ -1,7 +1,7 @@ // RUN: cp %s %t // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -// RUN: not %clang_cc1 -x c++ -fixit %t -Werror -DFIXIT -// RUN: %clang_cc1 -x c++ %t -DFIXIT +// RUN: not %clang_cc1 -x c++ -std=c++14 -fixit %t -Werror -DFIXIT +// RUN: %clang_cc1 -x c++ -std=c++14 %t -DFIXIT // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 -Wc++14-compat namespace foo1::foo2::foo3 { diff --git a/clang/test/Sema/ms_class_layout.cpp b/clang/test/Sema/ms_class_layout.cpp --- a/clang/test/Sema/ms_class_layout.cpp +++ b/clang/test/Sema/ms_class_layout.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts %s 2>/dev/null \ +// RUN: %clang_cc1 -std=c++14 -no-opaque-pointers -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts %s 2>/dev/null \ // RUN: | FileCheck %s --strict-whitespace #pragma pack(push, 8) diff --git a/clang/test/SemaCXX/MicrosoftExtensions.cpp b/clang/test/SemaCXX/MicrosoftExtensions.cpp --- a/clang/test/SemaCXX/MicrosoftExtensions.cpp +++ b/clang/test/SemaCXX/MicrosoftExtensions.cpp @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1 -// RUN: %clang_cc1 -std=c++98 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1 -// RUN: %clang_cc1 -std=c++11 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1 -// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fexceptions -fcxx-exceptions -DTEST2 +// RUN: %clang_cc1 -std=c++17 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1 +// RUN: %clang_cc1 -std=c++98 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify=expected,precxx17 -fms-extensions -fexceptions -fcxx-exceptions -DTEST1 +// RUN: %clang_cc1 -std=c++11 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify=expected,precxx17 -fms-extensions -fexceptions -fcxx-exceptions -DTEST1 +// RUN: %clang_cc1 -std=c++14 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify=expected,precxx17 -fexceptions -fcxx-exceptions -DTEST2 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -fms-compatibility -verify -DTEST3 #if TEST1 @@ -119,15 +119,15 @@ // We should accept type conversion of __unaligned to non-__unaligned references typedef struct in_addr { public: - in_addr(in_addr &a) {} // expected-note {{candidate constructor not viable: expects an lvalue for 1st argument}} - in_addr(in_addr *a) {} // expected-note {{candidate constructor not viable: no known conversion from 'IN_ADDR' (aka 'in_addr') to 'in_addr *' for 1st argument}} + in_addr(in_addr &a) {} // precxx17-note {{candidate constructor not viable: expects an lvalue for 1st argument}} + in_addr(in_addr *a) {} // precxx17-note {{candidate constructor not viable: no known conversion from 'IN_ADDR' (aka 'in_addr') to 'in_addr *' for 1st argument}} } IN_ADDR; void f(IN_ADDR __unaligned *a) { IN_ADDR local_addr = *a; // FIXME: MSVC accepts the following; not sure why clang tries to // copy-construct an in_addr. - IN_ADDR local_addr2 = a; // expected-error {{no viable constructor copying variable of type 'IN_ADDR' (aka 'in_addr')}} + IN_ADDR local_addr2 = a; // precxx17-error {{no viable constructor copying variable of type 'IN_ADDR' (aka 'in_addr')}} // expected-warning@-1 {{implicit cast from type '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to type 'in_addr *' drops __unaligned qualifier}} IN_ADDR local_addr3(a); // expected-warning@-1 {{implicit cast from type '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to type 'in_addr *' drops __unaligned qualifier}} diff --git a/clang/test/SemaCXX/PR12778.cpp b/clang/test/SemaCXX/PR12778.cpp --- a/clang/test/SemaCXX/PR12778.cpp +++ b/clang/test/SemaCXX/PR12778.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-dynamic-exception-spec -verify %s void operator delete() throw(void*); // expected-error{{'operator delete' must have at least one parameter}} void* allocate(int __n) { diff --git a/clang/test/SemaCXX/altivec.cpp b/clang/test/SemaCXX/altivec.cpp --- a/clang/test/SemaCXX/altivec.cpp +++ b/clang/test/SemaCXX/altivec.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -target-feature +altivec -flax-vector-conversions=none -triple powerpc-unknown-unknown -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -target-feature +altivec -flax-vector-conversions=none -triple powerpc-unknown-unknown -fcxx-exceptions -verify=expected,precxx17 %std_cxx98-14 %s +// RUN: %clang_cc1 -target-feature +altivec -flax-vector-conversions=none -triple powerpc-unknown-unknown -fcxx-exceptions -verify %std_cxx17- %s typedef int V4i __attribute__((vector_size(16))); @@ -62,7 +63,7 @@ vector float vf; vf++; - ++vi=vi; // expected-warning {{unsequenced}} + ++vi=vi; // precxx17-warning {{unsequenced}} (++vi)[1]=1; template_f(vi); } diff --git a/clang/test/SemaCXX/bool.cpp b/clang/test/SemaCXX/bool.cpp --- a/clang/test/SemaCXX/bool.cpp +++ b/clang/test/SemaCXX/bool.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion %s -// RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion \ -// RUN: -Wno-deprecated -Wdeprecated-increment-bool %s +// RUN: %clang_cc1 %std_cxx98-14 -fsyntax-only -verify=expected,precxx17 -Wno-constant-conversion %s +// RUN: %clang_cc1 %std_cxx98-14 -fsyntax-only -verify=expected,precxx17 -Wno-constant-conversion -Wno-deprecated -Wdeprecated-increment-bool %s +// RUN: %clang_cc1 %std_cxx17- -fsyntax-only -verify=expected,cxx17 -Wno-constant-conversion -Wno-deprecated -Wdeprecated-increment-bool %s // Bool literals can be enum values. enum { @@ -11,8 +11,10 @@ // bool cannot be decremented, and gives a warning on increment void test(bool b) { - ++b; // expected-warning {{incrementing expression of type bool is deprecated}} - b++; // expected-warning {{incrementing expression of type bool is deprecated}} + ++b; // precxx17-warning {{incrementing expression of type bool is deprecated}} \ + cxx17-error {{ISO C++17 does not allow incrementing expression of type bool}} + b++; // precxx17-warning {{incrementing expression of type bool is deprecated}} \ + cxx17-error {{ISO C++17 does not allow incrementing expression of type bool}} --b; // expected-error {{cannot decrement expression of type bool}} b--; // expected-error {{cannot decrement expression of type bool}} diff --git a/clang/test/SemaCXX/default2.cpp b/clang/test/SemaCXX/default2.cpp --- a/clang/test/SemaCXX/default2.cpp +++ b/clang/test/SemaCXX/default2.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx17 %std_cxx11-14 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17 %std_cxx17- %s void f(int i, int j, int k = 3); void f(int i, int j, int k); @@ -105,10 +106,10 @@ struct ZZ { static ZZ g(int = 17); - void f(ZZ z = g()); // expected-error{{no matching constructor for initialization}} \ - // expected-note{{passing argument to parameter 'z' here}} + void f(ZZ z = g()); // precxx17-error{{no matching constructor for initialization}} \ + // precxx17-note{{passing argument to parameter 'z' here}} - ZZ(ZZ&, int = 17); // expected-note{{candidate constructor}} + ZZ(ZZ&, int = 17); // precxx17-note{{candidate constructor}} }; // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#325 diff --git a/clang/test/SemaCXX/exception-spec-no-exceptions.cpp b/clang/test/SemaCXX/exception-spec-no-exceptions.cpp --- a/clang/test/SemaCXX/exception-spec-no-exceptions.cpp +++ b/clang/test/SemaCXX/exception-spec-no-exceptions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fobjc-exceptions %s +// RUN: %clang_cc1 %std_cxx98-14 -fsyntax-only -verify -fexceptions -fobjc-exceptions %s // expected-no-diagnostics // Note that we're specifically excluding -fcxx-exceptions in the command line above. diff --git a/clang/test/SemaCXX/exceptions.cpp b/clang/test/SemaCXX/exceptions.cpp --- a/clang/test/SemaCXX/exceptions.cpp +++ b/clang/test/SemaCXX/exceptions.cpp @@ -1,6 +1,5 @@ -// 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 +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify=expected,precxx17 %std_cxx98-14 %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %std_cxx17- %s struct A; // expected-note 4 {{forward declaration of 'A'}} @@ -128,6 +127,7 @@ } } +#if __cplusplus < 201703L namespace Decay { struct A { void f() throw (A[10]); @@ -165,6 +165,7 @@ #if __cplusplus <= 199711L // expected-warning@-2 {{rvalue references are a C++11 extension}} #endif +#endif namespace HandlerInversion { struct B {}; @@ -244,14 +245,14 @@ namespace ConstVolatileThrow { struct S { - S() {} // expected-note{{candidate constructor not viable}} - S(const S &s); // expected-note{{candidate constructor not viable}} + S() {} // precxx17-note{{candidate constructor not viable}} + S(const S &s); // precxx17-note{{candidate constructor not viable}} }; typedef const volatile S CVS; void f() { - throw CVS(); // expected-error{{no matching constructor for initialization}} + throw CVS(); // precxx17-error{{no matching constructor for initialization}} } } diff --git a/clang/test/SemaCXX/expressions.cpp b/clang/test/SemaCXX/expressions.cpp --- a/clang/test/SemaCXX/expressions.cpp +++ b/clang/test/SemaCXX/expressions.cpp @@ -10,6 +10,7 @@ int i = choice(!1); } +#if __cplusplus < 201703L // rdar://8018252 void f0() { extern void f0_1(int*); @@ -19,6 +20,7 @@ #endif f0_1(&x); } +#endif namespace test1 { template void bar(T &x) { T::fail(); } diff --git a/clang/test/SemaCXX/inline.cpp b/clang/test/SemaCXX/inline.cpp --- a/clang/test/SemaCXX/inline.cpp +++ b/clang/test/SemaCXX/inline.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s -Wpre-c++17-compat +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17-compat -std=c++17 %s -Wpre-c++17-compat // Check that we don't allow illegal uses of inline // (checking C++-only constructs here) @@ -14,5 +14,5 @@ #if __cplusplus <= 201402L inline int a; // expected-warning{{inline variables are a C++17 extension}} #else -inline int a; // expected-warning{{inline variables are incompatible with C++ standards before C++17}} +inline int a; // cxx17-compat-warning{{inline variables are incompatible with C++ standards before C++17}} #endif diff --git a/clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp b/clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp --- a/clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp +++ b/clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %std_cxx98-14 %s // This is a test for an egregious hack in Clang that works around // issues with GCC's evolution. libstdc++ 4.2.x uses __is_pod as an diff --git a/clang/test/SemaCXX/linkage2.cpp b/clang/test/SemaCXX/linkage2.cpp --- a/clang/test/SemaCXX/linkage2.cpp +++ b/clang/test/SemaCXX/linkage2.cpp @@ -173,7 +173,10 @@ }; } template void foo() {} - template void bar() {} // expected-note {{candidate function}} + template void bar() {} +#if __cplusplus < 201703L + // expected-note@-2 {{candidate function}} +#endif inline void *g() { struct L { }; @@ -181,7 +184,10 @@ // InternalLinkage in c++11) and VisibleNoLinkage. The correct answer is // NoLinkage in both cases. This means that using foo as a template // argument should fail. - return reinterpret_cast(bar), foo >); // expected-error {{reinterpret_cast cannot resolve overloaded function 'bar' to type 'void *}} + return reinterpret_cast(bar), foo >); +#if __cplusplus < 201703L + // expected-error@-2 {{reinterpret_cast cannot resolve overloaded function 'bar' to type 'void *}} +#endif } void h() { g(); diff --git a/clang/test/SemaCXX/member-pointer.cpp b/clang/test/SemaCXX/member-pointer.cpp --- a/clang/test/SemaCXX/member-pointer.cpp +++ b/clang/test/SemaCXX/member-pointer.cpp @@ -1,6 +1,4 @@ -// 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: %clang_cc1 -fsyntax-only -verify %std_cxx98- %s struct A {}; enum B { Dummy }; @@ -14,7 +12,10 @@ int A::*pdi1; int (::A::*pdi2); int (A::*pfi)(int); -void (*A::*ppfie)() throw(); // expected-error {{exception specifications are not allowed beyond a single level of indirection}} +void (*A::*ppfie)() throw(); +#if __cplusplus < 201703L +// expected-error@-2 {{exception specifications are not allowed beyond a single level of indirection}} +#endif int B::*pbi; #if __cplusplus <= 199711L // C++03 or earlier modes diff --git a/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp b/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp --- a/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp +++ b/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp @@ -62,6 +62,7 @@ nylinkedlist w; // expected-error{{unknown type name 'nylinkedlist'; did you mean 'realstd::mylinkedlist'?}} } +#if __cplusplus < 201703L // Test case from http://llvm.org/bugs/show_bug.cgi?id=10318 namespace llvm { template class GraphWriter {}; // expected-note 3{{declared here}} @@ -73,6 +74,7 @@ (void)new llvm::GraphWriter; // expected-error {{use of class template 'llvm::GraphWriter' requires template arguments}} (void)new llvm::Graphwriter; // expected-error {{no template named 'Graphwriter' in namespace 'llvm'; did you mean 'GraphWriter'?}} } +#endif // If namespace prefixes and character edits have the same weight, correcting // "fimish" to "N::famish" would have the same edit distance as correcting diff --git a/clang/test/SemaCXX/new-delete.cpp b/clang/test/SemaCXX/new-delete.cpp --- a/clang/test/SemaCXX/new-delete.cpp +++ b/clang/test/SemaCXX/new-delete.cpp @@ -1,7 +1,10 @@ -// 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 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++14 +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null %std_cxx17- + +// FIXME Location is (frontend) +// cxx17-note@*:* {{candidate function not viable: requires 2 arguments, but 3 were provided}} #include @@ -422,7 +425,11 @@ }; struct Y { // cv is ignored in arguments +#if __cplusplus < 202002L static void operator delete(void *volatile); +#else + static void operator delete(void *); +#endif }; } diff --git a/clang/test/SemaCXX/static-data-member.cpp b/clang/test/SemaCXX/static-data-member.cpp --- a/clang/test/SemaCXX/static-data-member.cpp +++ b/clang/test/SemaCXX/static-data-member.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -w %s +// RUN: %clang_cc1 %std_cxx98- -fsyntax-only -verify -w %s struct ABC { static double a; @@ -14,4 +14,6 @@ static double ABC::c = 1.0; // expected-error {{'static' can only be specified inside the class definition}} __private_extern__ double ABC::d = 1.0; // expected-error {{static data member definition cannot specify a storage class}} auto double ABC::e = 1.0; // expected-error {{static data member definition cannot specify a storage class}} +#if __cplusplus < 201703L register double ABC::f = 1.0; // expected-error {{static data member definition cannot specify a storage class}} +#endif diff --git a/clang/test/SemaCXX/type-definition-in-specifier.cpp b/clang/test/SemaCXX/type-definition-in-specifier.cpp --- a/clang/test/SemaCXX/type-definition-in-specifier.cpp +++ b/clang/test/SemaCXX/type-definition-in-specifier.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -Wno-dynamic-exception-spec -verify %std_cxx98- %s struct S0; struct S1; diff --git a/clang/test/SemaCXX/user-defined-conversions.cpp b/clang/test/SemaCXX/user-defined-conversions.cpp --- a/clang/test/SemaCXX/user-defined-conversions.cpp +++ b/clang/test/SemaCXX/user-defined-conversions.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx17 %std_cxx98-14 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected %std_cxx17- %s struct X { operator bool(); }; @@ -69,7 +70,7 @@ } struct X1 { - X1(X1&); // expected-note{{candidate constructor not viable: expects an lvalue for 1st argument}} + X1(X1&); // precxx17-note{{candidate constructor not viable: expects an lvalue for 1st argument}} }; struct X2 { @@ -80,7 +81,7 @@ float &f(...); void g(X2 b) { - int &ir = f(b); // expected-error{{no viable constructor copying parameter of type 'X1'}} + int &ir = f(b); // precxx17-error{{no viable constructor copying parameter of type 'X1'}} } namespace rdar10202900 { diff --git a/clang/test/SemaCXX/warn-new-overaligned-3.cpp b/clang/test/SemaCXX/warn-new-overaligned-3.cpp --- a/clang/test/SemaCXX/warn-new-overaligned-3.cpp +++ b/clang/test/SemaCXX/warn-new-overaligned-3.cpp @@ -1,4 +1,7 @@ -// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned %s -isystem %S/Inputs -verify +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned %s -isystem %S/Inputs -verify=precxx17 %std_cxx11-14 +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned %s -isystem %S/Inputs -verify %std_cxx17- + +// expected-no-diagnostics // This test ensures that we still get the warning even if we #include // where the header here simulates . @@ -16,8 +19,8 @@ void helper() { Test t; - new Test; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} - new Test[10]; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} + new Test; // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} + new Test[10]; // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} } } diff --git a/clang/test/SemaCXX/warn-new-overaligned.cpp b/clang/test/SemaCXX/warn-new-overaligned.cpp --- a/clang/test/SemaCXX/warn-new-overaligned.cpp +++ b/clang/test/SemaCXX/warn-new-overaligned.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify %s +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify=precxx17 %std_cxx98-14 %s +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify=cxx17 %std_cxx17- %s namespace test1 { struct Test { @@ -12,8 +13,8 @@ void helper() { Test t; - new Test; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} - new Test[10]; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} + new Test; // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} + new Test[10]; // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} } } @@ -25,8 +26,8 @@ void helper() { Test t; - new Test; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} - new Test[10]; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} + new Test; // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} + new Test[10]; // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} } } @@ -38,7 +39,8 @@ } __attribute__((aligned(256))); void* operator new(unsigned long) { - return 0; // expected-warning {{'operator new' should not return a null pointer unless it is declared 'throw()'}} + return 0; // precxx17-warning {{'operator new' should not return a null pointer unless it is declared 'throw()'}} \ + cxx17-warning {{'operator new' should not return a null pointer unless it is declared 'throw()' or 'noexcept'}} } SeparateCacheLines high_contention_data[10]; @@ -47,7 +49,7 @@ void helper() { Test t; new Test; - new Test[10]; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} + new Test[10]; // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} } } @@ -59,7 +61,8 @@ } __attribute__((aligned(256))); void* operator new[](unsigned long) { - return 0; // expected-warning {{'operator new[]' should not return a null pointer unless it is declared 'throw()'}} + return 0; // precxx17-warning {{'operator new[]' should not return a null pointer unless it is declared 'throw()'}} \ + cxx17-warning {{'operator new[]' should not return a null pointer unless it is declared 'throw()' or 'noexcept'}} } SeparateCacheLines high_contention_data[10]; @@ -67,7 +70,7 @@ void helper() { Test t; - new Test; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} + new Test; // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} new Test[10]; } } diff --git a/clang/test/SemaCXX/writable-strings-deprecated.cpp b/clang/test/SemaCXX/writable-strings-deprecated.cpp --- a/clang/test/SemaCXX/writable-strings-deprecated.cpp +++ b/clang/test/SemaCXX/writable-strings-deprecated.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -DWARNING +// RUN: %clang_cc1 -fsyntax-only -verify %std_cxx14- %s -DWARNING // RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s -DWARNING // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-deprecated-writable-strings -verify %s // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-deprecated -Wdeprecated-increment-bool -verify %s @@ -29,7 +29,9 @@ #endif } +#if __cplusplus < 201703L void test(bool b) { ++b; // expected-warning {{incrementing expression of type bool is deprecated}} } +#endif diff --git a/clang/test/SemaSYCL/zero-length-arrays.cpp b/clang/test/SemaSYCL/zero-length-arrays.cpp --- a/clang/test/SemaSYCL/zero-length-arrays.cpp +++ b/clang/test/SemaSYCL/zero-length-arrays.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsycl-is-device -triple spir64 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsycl-is-device -triple spir64 -fsyntax-only -verify -std=c++14 %s // // This test checks if compiler reports compilation error on an attempt to use // a zero-length array inside device code. diff --git a/clang/test/SemaTemplate/class-template-id.cpp b/clang/test/SemaTemplate/class-template-id.cpp --- a/clang/test/SemaTemplate/class-template-id.cpp +++ b/clang/test/SemaTemplate/class-template-id.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx23,precxx17 %std_cxx98-14 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx23,cxx17 %std_cxx17-20 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17,cxx23 %std_cxx23- %s template struct A { }; typedef A A_int; @@ -9,9 +11,11 @@ if (ptr) return ptr; // okay else if (ptr2) - return ptr2; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'const A *'}} + return ptr2; // precxx23-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'const A *'}} \ + cxx23-error{{cannot initialize return object of type 'A *' (aka 'A *') with an rvalue of type 'const A *'}} else { - return ptr3; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'A *'}} + return ptr3; // precxx23-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'A *'}} \ + cxx23-error{{cannot initialize return object of type 'A *' (aka 'A *') with an rvalue of type 'A *'}} } } @@ -24,7 +28,8 @@ else if (ptr2) return ptr2; else - return ptr3; // expected-error{{cannot initialize return object of type 'B<17 + 2> *' with an lvalue of type 'B<19 - 3>}} + return ptr3; // precxx23-error{{cannot initialize return object of type 'B<17 + 2> *' with an lvalue of type 'B<19 - 3>}} \ + cxx23-error{{cannot initialize return object of type 'B<17 + 2> *' with an rvalue of type 'B<19 - 3>}} } typedef B<5> B5; @@ -38,9 +43,12 @@ typedef N::C c2; // PR5655 -template struct Foo { }; // expected-note{{template is declared here}} +template struct Foo { }; // precxx17-note {{template is declared here}} \ + cxx17-note {{candidate template ignored: couldn't infer template argument 'T'}} \ + cxx17-note {{candidate function template not viable: requires 1 argument, but 0 were provided}} -void f(void) { Foo bar; } // expected-error{{use of class template 'Foo' requires template arguments}} +void f(void) { Foo bar; } // precxx17-error {{use of class template 'Foo' requires template arguments}} \ + cxx17-error {{no viable constructor or deduction guide for deduction of template arguments of 'Foo'}} // rdar://problem/8254267 template class Party; diff --git a/clang/test/SemaTemplate/constructor-template.cpp b/clang/test/SemaTemplate/constructor-template.cpp --- a/clang/test/SemaTemplate/constructor-template.cpp +++ b/clang/test/SemaTemplate/constructor-template.cpp @@ -1,6 +1,5 @@ -// 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: %clang_cc1 -fsyntax-only -verify=expected,precxx17 %std_cxx98-14 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s struct X0 { // expected-note {{candidate constructor (the implicit copy constructor) not viable}} #if __cplusplus >= 201103L // C++11 or later @@ -58,16 +57,16 @@ struct B { A x; B(B& a) : x(a.x) {} }; struct X2 { - X2(); // expected-note{{candidate constructor}} - X2(X2&); // expected-note {{candidate constructor}} - template X2(T); // expected-note {{candidate template ignored: instantiation would take its own class type by value}} + X2(); // precxx17-note{{candidate constructor}} + X2(X2&); // precxx17-note {{candidate constructor}} + template X2(T); // precxx17-note {{candidate template ignored: instantiation would take its own class type by value}} }; X2 test(bool Cond, X2 x2) { if (Cond) return x2; // okay, uses copy constructor - return X2(); // expected-error{{no matching constructor}} + return X2(); // precxx17-error{{no matching constructor}} } struct X3 { @@ -157,14 +156,14 @@ namespace self_by_value_2 { template struct A { - A() {} // expected-note {{not viable: requires 0 arguments}} - A(A &o) {} // expected-note {{not viable: expects an lvalue}} - A(A o) {} // expected-note {{ignored: instantiation takes its own class type by value}} + A() {} // precxx17-note {{not viable: requires 0 arguments}} + A(A &o) {} // precxx17-note {{not viable: expects an lvalue}} + A(A o) {} // precxx17-note {{ignored: instantiation takes its own class type by value}} }; - void helper_A(A); // expected-note {{passing argument to parameter here}} + void helper_A(A); // precxx17-note {{passing argument to parameter here}} void test_A() { - helper_A(A()); // expected-error {{no matching constructor}} + helper_A(A()); // precxx17-error {{no matching constructor}} } } diff --git a/clang/test/SemaTemplate/explicit-instantiation.cpp b/clang/test/SemaTemplate/explicit-instantiation.cpp --- a/clang/test/SemaTemplate/explicit-instantiation.cpp +++ b/clang/test/SemaTemplate/explicit-instantiation.cpp @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fcxx-exceptions -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fcxx-exceptions -Wno-dynamic-exception-spec %std_cxx11- %s template void *; // expected-error{{expected unqualified-id}} diff --git a/clang/test/SemaTemplate/instantiate-exception-spec.cpp b/clang/test/SemaTemplate/instantiate-exception-spec.cpp --- a/clang/test/SemaTemplate/instantiate-exception-spec.cpp +++ b/clang/test/SemaTemplate/instantiate-exception-spec.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -verify %s -DERRORS -// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -emit-llvm-only %s +// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -verify %std_cxx98-14 %s -DERRORS +// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -emit-llvm-only %std_cxx98-14 %s #ifdef ERRORS template void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}} diff --git a/clang/test/SemaTemplate/instantiate-non-dependent-types.cpp b/clang/test/SemaTemplate/instantiate-non-dependent-types.cpp --- a/clang/test/SemaTemplate/instantiate-non-dependent-types.cpp +++ b/clang/test/SemaTemplate/instantiate-non-dependent-types.cpp @@ -1,15 +1,15 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx17 %std_cxx98-14 %s +// RUN: %clang_cc1 -fsyntax-only -verify %std_cxx17- %s template struct X1 { - static void member() { T* x = 1; } // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} + static void member() { T* x = 1; } // precxx17-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} }; template struct instantiate { }; template struct X2 { - typedef instantiate<&X1::member> i; // expected-note{{in instantiation of}} + typedef instantiate<&X1::member> i; // precxx17-note{{in instantiation of}} }; X2 x; diff --git a/clang/test/SemaTemplate/instantiation-default-2.cpp b/clang/test/SemaTemplate/instantiation-default-2.cpp --- a/clang/test/SemaTemplate/instantiation-default-2.cpp +++ b/clang/test/SemaTemplate/instantiation-default-2.cpp @@ -1,7 +1,9 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx17,precxx20 %std_cxx98-14 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17,precxx20 -std=c++17 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 %std_cxx20- %s -template struct Constant; // expected-note{{template parameter is declared here}} \ -// FIXME: bad location expected-error{{a non-type template parameter cannot have type 'float'}} +template struct Constant; // precxx17-note{{template parameter is declared here}} \ +// FIXME: bad location precxx20-error{{a non-type template parameter cannot have type 'float'}} Constant *c1; @@ -13,6 +15,9 @@ Constant *c4; Constant *c5; -Constant *c6; // expected-error{{non-type template argument of type 'float (int, double)' cannot be converted to a value of type 'float (*)(int, int)'}} +Constant *c6; // precxx17-error {{non-type template argument of type 'float (int, double)' cannot be converted to a value of type 'float (*)(int, int)'}} \ + cxx17-error {{value of type 'float (int, double)' is not implicitly convertible to 'float (*)(int, int)'}} \ + cxx20-error {{value of type 'float (int, double)' is not implicitly convertible to 'float (*)(int, int)'}} -Constant *c7; // expected-note{{while substituting}} +Constant *c7; // precxx20-note {{while substituting}} \ + cxx20-error {{conversion from 'int' to 'float' is not allowed in a converted constant expression}} diff --git a/clang/test/SemaTemplate/temp_arg.cpp b/clang/test/SemaTemplate/temp_arg.cpp --- a/clang/test/SemaTemplate/temp_arg.cpp +++ b/clang/test/SemaTemplate/temp_arg.cpp @@ -1,8 +1,12 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx17 %std_cxx98-14 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17 %std_cxx17- %s template class TT> - class A; // expected-note 3 {{template is declared here}} + class A; // precxx17-note 3 {{template is declared here}} \ + cxx17-note 2 {{template is declared here}} \ + cxx17-note {{candidate template ignored: couldn't infer template argument 'T'}} \ + cxx17-note {{candidate function template not viable: requires 1 argument, but 0 were provided}} template class X; @@ -10,7 +14,8 @@ A *a2; // expected-error{{too many template arguments for class template 'A'}} A *a3; // expected-error{{too few template arguments for class template 'A'}} -A a4; // expected-error{{use of class template 'A' requires template arguments}} +A a4; // precxx17-error{{use of class template 'A' requires template arguments}} \ + cxx17-error{{no viable constructor or deduction guide for deduction of template arguments of 'A'}} namespace test0 { template class foo {}; diff --git a/clang/test/SemaTemplate/temp_arg_template.cpp b/clang/test/SemaTemplate/temp_arg_template.cpp --- a/clang/test/SemaTemplate/temp_arg_template.cpp +++ b/clang/test/SemaTemplate/temp_arg_template.cpp @@ -1,6 +1,5 @@ -// 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: %clang_cc1 -fsyntax-only -verify=expected,precxx17 %std_cxx98-14 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17 -std=c++17 %s template class X> struct A; // expected-note 2{{previous template template parameter is here}} @@ -42,7 +41,8 @@ // Do not do a digraph correction here. A<: :N::Z> *a11; // expected-error{{expected expression}} \ - expected-error{{a type specifier is required for all declarations}} + precxx17-error{{a type specifier is required for all declarations}} \ + cxx17-error{{expected unqualified-id}} // PR7807 namespace N { @@ -104,7 +104,8 @@ namespace CheckDependentNonTypeParamTypes { template class X> struct A { void f() { - X x; // expected-error {{does not refer to any declaration}} + X x; // precxx17-error {{does not refer to any declaration}} \ + cxx17-error {{value of type 'int' is not implicitly convertible to 'void *'}} } void g() { X x; @@ -123,7 +124,7 @@ } }; - template struct B { // expected-note {{parameter}} + template struct B { // precxx17-note {{parameter}} static const U value = v; }; diff --git a/clang/test/SemaTemplate/typename-specifier-3.cpp b/clang/test/SemaTemplate/typename-specifier-3.cpp --- a/clang/test/SemaTemplate/typename-specifier-3.cpp +++ b/clang/test/SemaTemplate/typename-specifier-3.cpp @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx17 %std_cxx11-14 %s +// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17 %std_cxx17- %s // PR4364 -template struct a { // expected-note {{here}} +template struct a { // precxx17-note {{here}} T b() { return typename T::x(); } @@ -16,8 +17,8 @@ // Some extra tests for invalid cases template struct test2 { T b() { return typename T::a; } }; // expected-error{{expected '(' for function-style cast or type construction}} -template struct test3 { T b() { return typename a; } }; // expected-error{{expected a qualified name after 'typename'}} -template struct test4 { T b() { return typename ::a; } }; // expected-error{{refers to non-type member}} expected-error{{expected '(' for function-style cast or type construction}} +template struct test3 { T b() { return typename a; } }; // expected-error{{expected a qualified name after 'typename'}} cxx17-error{{expected '(' for function-style cast or type construction}} +template struct test4 { T b() { return typename ::a; } }; // precxx17-error{{refers to non-type member}} expected-error{{expected '(' for function-style cast or type construction}} // PR12884 namespace PR12884_original { diff --git a/clang/unittests/AST/ASTTraverserTest.cpp b/clang/unittests/AST/ASTTraverserTest.cpp --- a/clang/unittests/AST/ASTTraverserTest.cpp +++ b/clang/unittests/AST/ASTTraverserTest.cpp @@ -280,7 +280,7 @@ TEST(Traverse, IgnoreUnlessSpelledInSourceVars) { - auto AST = buildASTFromCode(R"cpp( + auto AST = buildASTFromCodeWithArgs(R"cpp( struct String { @@ -346,7 +346,7 @@ } } -)cpp"); +)cpp", {"-std=c++14"}); { auto FN = @@ -715,7 +715,7 @@ TEST(Traverse, IgnoreUnlessSpelledInSourceReturns) { - auto AST = buildASTFromCode(R"cpp( + auto AST = buildASTFromCodeWithArgs(R"cpp( struct A { @@ -784,7 +784,7 @@ return c; } -)cpp"); +)cpp", {"-std=c++14"}); auto getFunctionNode = [&AST](const std::string &name) { auto BN = ast_matchers::match(functionDecl(hasName(name)).bind("fn"), diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py --- a/llvm/utils/lit/lit/llvm/config.py +++ b/llvm/utils/lit/lit/llvm/config.py @@ -567,6 +567,32 @@ self.config.substitutions.append( ('%target_itanium_abi_host_triple', '')) + # TODO: Many tests work across many language standards. Before + # https://discourse.llvm.org/t/lit-run-a-run-line-multiple-times-with-different-replacements/64932 + # has a solution, provide substitutions to conveniently try every standard with LIT_CLANG_STD_GROUP. + clang_std_group = int(os.environ.get('LIT_CLANG_STD_GROUP', '0')) + clang_std_values = ('98', '11', '14', '17', '20', '2b') + def add_std_cxx(s): + t = s[8:] + if t.endswith('-'): + t += clang_std_values[-1] + l = clang_std_values.index(t[0:2] if t[0:2] != '23' else '2b') + h = clang_std_values.index(t[3:5]) + # Let LIT_CLANG_STD_GROUP=0 pick the highest value (likely the most relevant + # standard). + l = h - clang_std_group % (h-l+1) + self.config.substitutions.append((s, '-std=c++' + clang_std_values[l])) + + add_std_cxx('%std_cxx98-14') + add_std_cxx('%std_cxx98-') + add_std_cxx('%std_cxx11-14') + add_std_cxx('%std_cxx11-') + add_std_cxx('%std_cxx14-') + add_std_cxx('%std_cxx17-20') + add_std_cxx('%std_cxx17-') + add_std_cxx('%std_cxx20-') + add_std_cxx('%std_cxx23-') + # FIXME: Find nicer way to prohibit this. def prefer(this, to): return '''\"*** Do not use '%s' in tests, use '%s'. ***\"''' % (