Author: Fangrui Song Date: 2022-09-04T05:29:32Z New Revision: 83ea47acd7116bf50274534ba9b3bd3035c01da6
URL: https://github.com/llvm/llvm-project/commit/83ea47acd7116bf50274534ba9b3bd3035c01da6 DIFF: https://github.com/llvm/llvm-project/commit/83ea47acd7116bf50274534ba9b3bd3035c01da6.diff LOG: [test] Make tests pass regardless of gnu++14/gnu++17 default GCC from 11 onwards defaults to -std=gnu++17 for C++ source files. We want to do the same (https://discourse.llvm.org/t/c-objc-switch-to-gnu-17-as-the-default-dialect/64360). Split RUN lines, adjust `-verify`, or add `__cplusplus < 201703L` or `-Wno-dynamic-exception-spec`, so that tests will pass regardless of gnu++14/gnu++17 default. We have a desire to mark a test compatible with multiple language standards. There are ongoing discussions how to add markers in the long term: * https://discourse.llvm.org/t/iterating-lit-run-lines/62596 * https://discourse.llvm.org/t/lit-run-a-run-line-multiple-times-with-different-replacements/64932 As a workaround in the short term, add lit substitutions `%std_cxx98-`, `%std_cxx11-14`, etc. They can be used for tests which work across multiple language standards. If a range has `n` standards, run lit multiple times, with `LIT_CLANG_STD_GROUP=0`, `LIT_CLANG_STD_GROUP=1`, etc to cover all `n` standards. Reviewed By: #clang-language-wg, aaron.ballman Differential Revision: https://reviews.llvm.org/D131464 Added: Modified: clang/test/AST/ast-dump-openmp-begin-declare-variant_11.c clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp clang/test/AST/ast-dump-undeduced-expr.cpp clang/test/AST/sourceranges.cpp clang/test/Analysis/blocks.m clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp clang/test/CXX/class.access/class.friend/p1.cpp clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp clang/test/CXX/except/except.spec/p2-dynamic-types.cpp clang/test/CXX/except/except.spec/p9-dynamic.cpp clang/test/CXX/stmt.stmt/stmt.select/p3.cpp clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp clang/test/CXX/temp/temp.res/temp.local/p3.cpp clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp clang/test/CodeGenCXX/align-avx-complete-objects.cpp clang/test/CodeGenCXX/copy-constructor-elim-2.cpp clang/test/CodeGenCXX/debug-info-template-parameter.cpp clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp clang/test/CodeGenCXX/exception-spec-decay.cpp clang/test/CodeGenCXX/exceptions-cxx-ehsc.cpp clang/test/CodeGenCXX/exceptions-no-rtti.cpp clang/test/CodeGenCXX/global-init.cpp clang/test/CodeGenCXX/no-exceptions.cpp clang/test/CodeGenCXX/override-bit-field-layout.cpp clang/test/CodeGenCXX/override-layout.cpp clang/test/CodeGenCXX/reference-temporary-ms.cpp clang/test/CodeGenCXX/rtti-linkage.cpp clang/test/Layout/ms-x86-vtordisp.cpp clang/test/Modules/update-exception-spec.cpp clang/test/OpenMP/declare_mapper_messages.cpp clang/test/PCH/cxx-functions.cpp clang/test/Parser/cxx-casting.cpp clang/test/Parser/cxx-class.cpp clang/test/Parser/cxx-template-argument.cpp clang/test/Parser/cxx-template-decl.cpp clang/test/Parser/cxx1z-nested-namespace-definition.cpp clang/test/Sema/ms_class_layout.cpp clang/test/SemaCXX/MicrosoftExtensions.cpp clang/test/SemaCXX/PR12778.cpp clang/test/SemaCXX/altivec.cpp clang/test/SemaCXX/bool.cpp clang/test/SemaCXX/default2.cpp clang/test/SemaCXX/exception-spec-no-exceptions.cpp clang/test/SemaCXX/exceptions.cpp clang/test/SemaCXX/expressions.cpp clang/test/SemaCXX/inline.cpp clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp clang/test/SemaCXX/linkage2.cpp clang/test/SemaCXX/member-pointer.cpp clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp clang/test/SemaCXX/new-delete.cpp clang/test/SemaCXX/static-data-member.cpp clang/test/SemaCXX/type-definition-in-specifier.cpp clang/test/SemaCXX/user-defined-conversions.cpp clang/test/SemaCXX/warn-new-overaligned-3.cpp clang/test/SemaCXX/warn-new-overaligned.cpp clang/test/SemaCXX/writable-strings-deprecated.cpp clang/test/SemaSYCL/zero-length-arrays.cpp clang/test/SemaTemplate/class-template-id.cpp clang/test/SemaTemplate/constructor-template.cpp clang/test/SemaTemplate/explicit-instantiation.cpp clang/test/SemaTemplate/instantiate-exception-spec.cpp clang/test/SemaTemplate/instantiate-non-dependent-types.cpp clang/test/SemaTemplate/instantiation-default-2.cpp clang/test/SemaTemplate/temp_arg.cpp clang/test/SemaTemplate/temp_arg_template.cpp clang/test/SemaTemplate/typename-specifier-3.cpp clang/unittests/AST/ASTTraverserTest.cpp llvm/utils/lit/lit/llvm/config.py Removed: ################################################################################ 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 index 3e5eb4cb5cd7e..4c99f3311d8c3 100644 --- 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 @@ CONST int also_after1(void) { // cxx_mode-note {{previous declaration is here}} 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_after1(void) { // cxx_mode-error {{non-constexpr declaration of 'also_a 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 index 37490b9fdb30d..60619801735f2 100644 --- 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 <typename T> struct S { S(int, T *) {} }; @@ -53,7 +53,7 @@ int test() { // 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:23, col:30> col:30 implicit referenced struct S // CHECK-NEXT: | | `-CXXConstructorDecl [[ADDR_4:0x[a-z0-9]*]] <line:6:3, col:16> col:3 S<T> 'void (int, T *)' // CHECK-NEXT: | | |-ParmVarDecl [[ADDR_5:0x[a-z0-9]*]] <col:5> col:8 'int' @@ -76,10 +76,12 @@ int test() { // CHECK-NEXT: | | | `-CompoundStmt [[ADDR_7]] <col:15, col:16> // CHECK-NEXT: | | |-CXXConstructorDecl [[ADDR_14:0x[a-z0-9]*]] <line:5:30> col:30 implicit constexpr S 'void (const S<int> &)' inline default trivial noexcept-unevaluated [[ADDR_14]] // CHECK-NEXT: | | | `-ParmVarDecl [[ADDR_15:0x[a-z0-9]*]] <col:30> col:30 'const S<int> &' -// CHECK-NEXT: | | |-CXXConstructorDecl [[ADDR_16:0x[a-z0-9]*]] <col:30> col:30 implicit used constexpr S 'void (S<int> &&) noexcept' inline default trivial -// CHECK-NEXT: | | | |-ParmVarDecl [[ADDR_17:0x[a-z0-9]*]] <col:30> col:30 'S<int> &&' -// CHECK-NEXT: | | | `-CompoundStmt [[ADDR_18:0x[a-z0-9]*]] <col:30> -// CHECK-NEXT: | | `-CXXDestructorDecl [[ADDR_19:0x[a-z0-9]*]] <col:30> col:30 implicit referenced ~S 'void ({{.*}}) noexcept' inline default trivial +// CXX11-NEXT: | | |-CXXConstructorDecl [[ADDR_16:0x[a-z0-9]*]] <col:30> col:30 implicit used constexpr S 'void (S<int> &&) noexcept' inline default trivial +// CXX11-NEXT: | | | |-ParmVarDecl [[ADDR_17:0x[a-z0-9]*]] <col:30> col:30 'S<int> &&' +// CXX11-NEXT: | | | `-CompoundStmt [[ADDR_18:0x[a-z0-9]*]] <col:30> +// CXX17-NEXT: | | |-CXXConstructorDecl [[ADDR_16:0x[a-z0-9]*]] <col:30> col:30 implicit constexpr S 'void (S<int> &&)' inline default trivial noexcept-unevaluated +// CXX17-NEXT: | | | `-ParmVarDecl [[ADDR_17:0x[a-z0-9]*]] <col:30> col:30 'S<int> &&' +// CHECK-NEXT: | | `-CXXDestructorDecl [[ADDR_19:0x[a-z0-9]*]] <col:30> col:30 implicit referenced {{(constexpr )?}}~S 'void ({{.*}}) noexcept' inline default trivial // CHECK-NEXT: | `-ClassTemplateSpecializationDecl [[ADDR_20:0x[a-z0-9]*]] <col:1, line:7:1> line:5:30 struct S // CHECK-NEXT: | `-TemplateArgument type 'double' // CHECK-NEXT: | `-BuiltinType [[ADDR_21:0x[a-z0-9]*]] 'double' @@ -216,7 +218,7 @@ int test() { // CHECK-NEXT: `-FunctionDecl [[ADDR_126:0x[a-z0-9]*]] <line:42:1, line:45:1> line:42:5 test 'int ({{.*}})' // CHECK-NEXT: `-CompoundStmt [[ADDR_127:0x[a-z0-9]*]] <col:12, line:45:1> // CHECK-NEXT: `-ReturnStmt [[ADDR_128:0x[a-z0-9]*]] <line:44:3, col:98> -// CHECK-NEXT: `-ExprWithCleanups [[ADDR_129:0x[a-z0-9]*]] <col:10, col:98> 'int' +// CXX11-NEXT: `-ExprWithCleanups [[ADDR_129:0x[a-z0-9]*]] <col:10, col:98> 'int' // CHECK-NEXT: `-BinaryOperator [[ADDR_130:0x[a-z0-9]*]] <col:10, col:98> 'int' '+' // CHECK-NEXT: |-BinaryOperator [[ADDR_131:0x[a-z0-9]*]] <col:10, col:74> 'int' '+' // CHECK-NEXT: | |-BinaryOperator [[ADDR_132:0x[a-z0-9]*]] <col:10, col:57> 'int' '+' @@ -241,8 +243,8 @@ int test() { // CHECK-NEXT: |-CallExpr [[ADDR_151:0x[a-z0-9]*]] <col:78, col:98> 'int' // CHECK-NEXT: | |-ImplicitCastExpr [[ADDR_152:0x[a-z0-9]*]] <col:78> 'int (*)(S<int>)' <FunctionToPointerDecay> // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_153:0x[a-z0-9]*]] <col:78> 'int (S<int>)' {{.*}}Function [[ADDR_65]] 'special' 'int (S<int>)' (FunctionTemplate [[ADDR_58]] 'special') -// CHECK-NEXT: | `-CXXConstructExpr [[ADDR_154:0x[a-z0-9]*]] <col:86, col:97> 'S<int>':'S<int>' 'void (S<int> &&) noexcept' elidable -// CHECK-NEXT: | `-MaterializeTemporaryExpr [[ADDR_155:0x[a-z0-9]*]] <col:86, col:97> 'S<int>':'S<int>' xvalue +// CXX11-NEXT: | `-CXXConstructExpr [[ADDR_154:0x[a-z0-9]*]] <col:86, col:97> 'S<int>':'S<int>' 'void (S<int> &&) noexcept' elidable +// CXX11-NEXT: | `-MaterializeTemporaryExpr [[ADDR_155:0x[a-z0-9]*]] <col:86, col:97> 'S<int>':'S<int>' xvalue // CHECK-NEXT: | `-CXXTemporaryObjectExpr [[ADDR_156:0x[a-z0-9]*]] <col:86, col:97> 'S<int>':'S<int>' 'void (int, int *)' // CHECK-NEXT: | |-IntegerLiteral [[ADDR_157:0x[a-z0-9]*]] <col:93> 'int' 0 // CHECK-NEXT: | `-ImplicitCastExpr [[ADDR_158:0x[a-z0-9]*]] <col:96> 'int *' <NullToPointer> @@ -250,9 +252,10 @@ int test() { // CHECK-NEXT: `-CallExpr [[ADDR_160:0x[a-z0-9]*]] <line:23:1, line:44:98> 'int' // CHECK-NEXT: |-ImplicitCastExpr [[ADDR_161:0x[a-z0-9]*]] <line:23:1> 'int (*)(S<int>)' <FunctionToPointerDecay> // CHECK-NEXT: | `-DeclRefExpr [[ADDR_68]] <col:1> 'int (S<int>)' {{.*}}Function [[ADDR_69]] 'special[implementation={extension(allow_templates)}]' 'int (S<int>)' -// CHECK-NEXT: `-CXXConstructExpr [[ADDR_162:0x[a-z0-9]*]] <line:44:86, col:97> 'S<int>':'S<int>' 'void (S<int> &&) noexcept' elidable -// CHECK-NEXT: `-MaterializeTemporaryExpr [[ADDR_163:0x[a-z0-9]*]] <col:86, col:97> 'S<int>':'S<int>' xvalue -// CHECK-NEXT: `-CXXTemporaryObjectExpr [[ADDR_156]] <col:86, col:97> 'S<int>':'S<int>' 'void (int, int *)' +// CXX11-NEXT: `-CXXConstructExpr [[ADDR_162:0x[a-z0-9]*]] <line:44:86, col:97> 'S<int>':'S<int>' 'void (S<int> &&) noexcept' elidable +// CXX11-NEXT: `-MaterializeTemporaryExpr [[ADDR_163:0x[a-z0-9]*]] <col:86, col:97> 'S<int>':'S<int>' xvalue +// CXX11-NEXT: `-CXXTemporaryObjectExpr [[ADDR_156]] <col:86, col:97> 'S<int>':'S<int>' 'void (int, int *)' +// CXX17-NEXT: `-CXXTemporaryObjectExpr [[ADDR_156]] <line:[[#]]:86, col:97> 'S<int>':'S<int>' 'void (int, int *)' // CHECK-NEXT: |-IntegerLiteral [[ADDR_157]] <col:93> 'int' 0 // CHECK-NEXT: `-ImplicitCastExpr [[ADDR_158]] <col:96> 'int *' <NullToPointer> // CHECK-NEXT: `-IntegerLiteral [[ADDR_159]] <col:96> 'int' 0 diff --git a/clang/test/AST/ast-dump-undeduced-expr.cpp b/clang/test/AST/ast-dump-undeduced-expr.cpp index d404db9285974..09eeb9eab8283 100644 --- a/clang/test/AST/ast-dump-undeduced-expr.cpp +++ b/clang/test/AST/ast-dump-undeduced-expr.cpp @@ -4,4 +4,4 @@ struct Foo { 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 index 665fd0c3295b3..40135bd2e17c6 100644 --- 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 T> class P { diff --git a/clang/test/Analysis/blocks.m b/clang/test/Analysis/blocks.m index be3964f2f6ef5..d2c8af5310127 100644 --- 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 index 0511280ae2ba4..f2628ee686632 100644 --- 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 index 257aca1c3f7bf..a5d80fd0ce3fb 100644 --- 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 @@ void* operator new(std::size_t) throw(std::bad_alloc); #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 index a600ae2b4f8e7..4b18036365c1c 100644 --- a/clang/test/CXX/class.access/class.friend/p1.cpp +++ b/clang/test/CXX/class.access/class.friend/p1.cpp @@ -221,13 +221,21 @@ namespace test6 { #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 @@ namespace test7 { #if __cplusplus >= 201103L constexpr #endif - X<int>::X(const X&); + X<int>::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 index 13721518e6f9e..723a79628116c 100644 --- 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 @@ auto void af(); // expected-error {{illegal storage class on function}} #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 @@ struct S { }; 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 @@ void foo(auto int ap, register int rp) { #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 index 57f8c3251a1cb..5ab7a641aea85 100644 --- 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 index 5a176b222bb74..70cd630840a33 100644 --- 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 index 2d45d82d43754..067039aa47393 100644 --- 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 index 47bb95f2c024d..41a627071f0e6 100644 --- a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp +++ b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp @@ -1,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 @@ namespace non_type_tmpl_param { // 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 <int* p> struct X0 { }; // expected-note 5{{here}} + template <int* p> 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 <int (*fp)(int)> struct X1 { }; - template <int &p> struct X2 { }; // expected-note 4{{here}} - template <const int &p> struct X2k { }; // expected-note {{here}} - template <int (&fp)(int)> struct X3 { }; // expected-note 4{{here}} + template <int &p> struct X2 { }; // precxx17-note 4{{here}} + template <const int &p> struct X2k { }; // precxx17-note {{here}} + template <int (&fp)(int)> 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 @@ namespace addr_of_obj_or_func { // 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 @@ namespace addr_of_obj_or_func { #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<iarr> x0b; - X0<&iarr> x0b_addr; // expected-error {{cannot be converted to a value of type 'int *'}} - X0<ki> 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<ki> 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 @@ namespace addr_of_obj_or_func { #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<f> x1a; @@ -112,10 +113,10 @@ namespace addr_of_obj_or_func { #endif X2<i> x2a; - X2<&i> x2a_addr; // expected-error {{address taken}} - X2<iarr> x2b; // expected-error {{cannot bind to template argument of type 'int[10]'}} - X2<&iarr> x2b_addr; // expected-error {{address taken}} - X2<ki> 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<iarr> 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<ki> 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 @@ namespace addr_of_obj_or_func { // 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<ti> x2d_addr; // expected-error {{refers to thread-local object}} + X2<ti> x2d_addr; // precxx17-error {{refers to thread-local object}} cxx17-error {{non-type template argument is not a constant expression}} X3<f> 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<f_tmpl> x3b; - X3<&f_tmpl> x3b_addr; // expected-error {{address taken}} + X3<&f_tmpl> x3b_addr; // precxx17-error {{address taken}} cxx17-error {{value of type '<overloaded function type>' is not implicitly convertible to 'int (&)(int)'}} X3<f_tmpl<int> > x3c; - X3<&f_tmpl<int> > x3c_addr; // expected-error {{address taken}} + X3<&f_tmpl<int> > x3c_addr; // precxx17-error {{address taken}} cxx17-error {{value of type '<overloaded function type>' is not implicitly convertible to 'int (&)(int)'}} X3<f_internal> 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 @@ namespace addr_of_obj_or_func { #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 @@ namespace addr_of_obj_or_func { // -- a pointer to member expressed as described in 5.3.1. namespace bad_args { - template <int* N> struct X0 { }; // expected-note 2{{template parameter is declared here}} + template <int* N> 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 @@ namespace bad_args { #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 index 880931612bd23..5e8a233d76d93 100644 --- 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 <class T> struct Base { // expected-note@-1 2{{member type 'Base<int>' found by ambiguous name lookup}} @@ -26,7 +27,9 @@ namespace PR6717 { } // expected-error {{expected ';' after class}} WebVector(const WebVector<T>& 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 <typename C> WebVector<T>& 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 index 1e6888de60e6b..dba537a6e6eea 100644 --- 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 @@ void test8() { 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 index cac6a61892ca9..2f8a09b6fbe5f 100644 --- 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 @@ volatile float TestAlign(void) } // 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_Explicitly_aligned AVX2Float_indirect; 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 @@ volatile float TestAlign2(void) } // 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 index 6337afa33bd1c..195c92c301c86 100644 --- 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 @@ A f() { return A(0); } // 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 @@ namespace no_elide_base { // 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 @@ namespace ElidableCallIsNotCopyCtor { 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 index fee6dfe8b898e..dac7871803c5b 100644 --- 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 <typename T = char, int i = 3, bool b = true, int x = sizeof(T)> class foo { diff --git a/clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp b/clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp index 0435a6fd3d7cc..1595bf8b2178c 100644 --- 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 <class _Tp, class _Dp, bool > struct __pointer_type1 {}; @@ -17,7 +18,8 @@ struct __pointer_type2 // 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 <class _Tp> struct default_delete {}; diff --git a/clang/test/CodeGenCXX/exception-spec-decay.cpp b/clang/test/CodeGenCXX/exception-spec-decay.cpp index 49283539070c2..61d9d3df5175c 100644 --- 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 index ae1f463d386c9..0a77523a3557f 100644 --- 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 index e1ef4f1ddad78..7c73285b948f1 100644 --- 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 index 1cef8bcc41899..6204a2e54a66e 100644 --- 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 @@ namespace test7 { 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<const C&>(C()); const int c3 = C().n; diff --git a/clang/test/CodeGenCXX/no-exceptions.cpp b/clang/test/CodeGenCXX/no-exceptions.cpp index 52ce0baa3174a..47f491e50e8f1 100644 --- 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 index dee7944f6a5ed..cdafc07c84ff0 100644 --- 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 @@ struct S2 { 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 index fea2a45c6299d..07cd31580726e 100644 --- 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 @@ struct PACKED X5 { 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 index 25f3f0378b3c8..15174b1b9b955 100644 --- 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 index 966cab6eb31f7..9a2791670bbd9 100644 --- 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 <typeinfo> diff --git a/clang/test/Layout/ms-x86-vtordisp.cpp b/clang/test/Layout/ms-x86-vtordisp.cpp index 67e03aa92914d..9f85edff58508 100644 --- 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 index f678f6e76ecc2..4d97c5ac281a4 100644 --- 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 index c50df694f70a3..253d12ad1244a 100644 --- 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 @@ class stack { // expec }; }; -#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<int> s) map(s.data) #pragma omp declare mapper(default : S<int> 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 index 3b4fe77c044a2..9a576f1c12119 100644 --- 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 index b1ae591865eb1..34c3a1a2460b5 100644 --- 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 index efd1a6dc03e77..046d2dd580f02 100644 --- 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 index a42a473409eed..667dd8698435b 100644 --- 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 index 55c71b46da75d..39162c574d08c 100644 --- 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 index e0c5244a37348..b2d6d3253c70e 100644 --- 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 index 8b12f44978b0f..ce5ff7563f4dc 100644 --- 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 index 8c1644589cab0..7f9681dcda445 100644 --- 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 @@ __inline void FreeIDListArray(LPITEMIDLIST *ppidls) { // 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 index f4d25f3e8fc93..62183720e2caa 100644 --- 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 index 2ba3400ca127f..09d3dc890ad5d 100644 --- 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 @@ void test2() 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 index 69c0119357814..33e22c8f6d36f 100644 --- 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 @@ enum { // 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 index c51d272853e72..355a96bbcb99f 100644 --- 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 @@ void test_Z(const Z& z) { 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 index e26e864e3d8f1..45d05f36c819f 100644 --- 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 index bd56fbf02ee02..3a410b1bfe439 100644 --- 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 @@ namespace PR6831 { } } +#if __cplusplus < 201703L namespace Decay { struct A { void f() throw (A[10]); @@ -165,6 +165,7 @@ void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int & #if __cplusplus <= 199711L // expected-warning@-2 {{rvalue references are a C++11 extension}} #endif +#endif namespace HandlerInversion { struct B {}; @@ -244,14 +245,14 @@ void f8() { 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 index 5a0d6dd0670c9..641cfc8af7ce9 100644 --- a/clang/test/SemaCXX/expressions.cpp +++ b/clang/test/SemaCXX/expressions.cpp @@ -10,6 +10,7 @@ void test() { int i = choice(!1); } +#if __cplusplus < 201703L // rdar://8018252 void f0() { extern void f0_1(int*); @@ -19,6 +20,7 @@ void f0() { #endif f0_1(&x); } +#endif namespace test1 { template <class T> void bar(T &x) { T::fail(); } diff --git a/clang/test/SemaCXX/inline.cpp b/clang/test/SemaCXX/inline.cpp index 1a13609eb5783..a92e399399517 100644 --- 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 @@ void localVar() { #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 index 8d187124f013a..a853a484707df 100644 --- 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 index 6fd0081450bf6..f4192d34c66ab 100644 --- a/clang/test/SemaCXX/linkage2.cpp +++ b/clang/test/SemaCXX/linkage2.cpp @@ -173,7 +173,10 @@ namespace test17 { }; } template <typename T1, typename T2> void foo() {} - template <typename T, T x> void bar() {} // expected-note {{candidate function}} + template <typename T, T x> void bar() {} +#if __cplusplus < 201703L + // expected-note@-2 {{candidate function}} +#endif inline void *g() { struct L { }; @@ -181,7 +184,10 @@ namespace test17 { // InternalLinkage in c++11) and VisibleNoLinkage. The correct answer is // NoLinkage in both cases. This means that using foo<L, I> as a template // argument should fail. - return reinterpret_cast<void*>(bar<typeof(foo<L, I>), foo<L, I> >); // expected-error {{reinterpret_cast cannot resolve overloaded function 'bar' to type 'void *}} + return reinterpret_cast<void*>(bar<typeof(foo<L, I>), foo<L, I> >); +#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 index f3adb95977a14..ec27d7abeadb8 100644 --- 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 @@ class H : A {}; // expected-note 2{{implicitly declared private here}} 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 index 6195e03955154..9d05d64ab4062 100644 --- a/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp +++ b/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp @@ -62,6 +62,7 @@ void f() { 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 <typename T> class GraphWriter {}; // expected-note 3{{declared here}} @@ -73,6 +74,7 @@ void bar() { (void)new llvm::GraphWriter; // expected-error {{use of class template 'llvm::GraphWriter' requires template arguments}} (void)new llvm::Graphwriter<S>; // 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 index 39f03dcc6f03d..9923a9ed29d92 100644 --- 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 <stddef.h> @@ -422,7 +425,11 @@ namespace PR7810 { }; 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 index 9fe87b1c1d3c8..fb63da9b40099 100644 --- 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 @@ extern double ABC::b = 1.0; // expected-error {{static data member definition ca 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 index 2da649fdb0b8d..f6ad6b7e3108f 100644 --- 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 index 30b98dc9935d8..fed1cc6eabef4 100644 --- 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 @@ void test_conversion(ConvertibleToBase ctb, ConvertibleToDerived ctd, } 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 @@ int &f(X1); 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 index ba14303fb9d84..8d071b4d93a74 100644 --- 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 <new> // where the header here simulates <new>. @@ -16,8 +19,8 @@ struct Test { 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 index c5495e312dcc6..5b84ce7e496cd 100644 --- 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 @@ struct Test { 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 @@ class Test { 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 @@ struct Test { } __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<int> high_contention_data[10]; @@ -47,7 +49,7 @@ struct Test { 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 @@ struct Test { } __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<int> high_contention_data[10]; @@ -67,7 +70,7 @@ struct Test { 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 index 7de11b59dd11d..8b95c7f6f28d3 100644 --- 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 @@ char *fun(void) #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 index d2b8d767eedcf..01db92075ba95 100644 --- 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 index 50cb3ef59ea41..0752800d04084 100644 --- 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<typename T, typename U = float> struct A { }; typedef A<int> A_int; @@ -9,9 +11,11 @@ A<int, FLOAT> *foo(A<int> *ptr, A<int> const *ptr2, A<int, double> *ptr3) { if (ptr) return ptr; // okay else if (ptr2) - return ptr2; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'const A<int> *'}} + return ptr2; // precxx23-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'const A<int> *'}} \ + cxx23-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an rvalue of type 'const A<int> *'}} else { - return ptr3; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'A<int, double> *'}} + return ptr3; // precxx23-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'A<int, double> *'}} \ + cxx23-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an rvalue of type 'A<int, double> *'}} } } @@ -24,7 +28,8 @@ B<17 + 2> *bar(B<(19)> *ptr1, B< (::value + 7) > *ptr2, B<19 - 3> *ptr3) { 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 @@ N::C<int> c1; typedef N::C<float> c2; // PR5655 -template<typename T> struct Foo { }; // expected-note{{template is declared here}} +template<typename T> 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 <typename T> class Party; diff --git a/clang/test/SemaTemplate/constructor-template.cpp b/clang/test/SemaTemplate/constructor-template.cpp index ca917d7c643f6..f9cd6c78a43e3 100644 --- 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 @@ template <> struct A<int>{A(const A<int>&);}; struct B { A<int> x; B(B& a) : x(a.x) {} }; struct X2 { - X2(); // expected-note{{candidate constructor}} - X2(X2&); // expected-note {{candidate constructor}} - template<typename T> 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<typename T> 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 { namespace self_by_value_2 { template <class T, class U> struct A { - A() {} // expected-note {{not viable: requires 0 arguments}} - A(A<T,U> &o) {} // expected-note {{not viable: expects an lvalue}} - A(A<T,T> o) {} // expected-note {{ignored: instantiation takes its own class type by value}} + A() {} // precxx17-note {{not viable: requires 0 arguments}} + A(A<T,U> &o) {} // precxx17-note {{not viable: expects an lvalue}} + A(A<T,T> o) {} // precxx17-note {{ignored: instantiation takes its own class type by value}} }; - void helper_A(A<int,int>); // expected-note {{passing argument to parameter here}} + void helper_A(A<int,int>); // precxx17-note {{passing argument to parameter here}} void test_A() { - helper_A(A<int,int>()); // expected-error {{no matching constructor}} + helper_A(A<int,int>()); // precxx17-error {{no matching constructor}} } } diff --git a/clang/test/SemaTemplate/explicit-instantiation.cpp b/clang/test/SemaTemplate/explicit-instantiation.cpp index 73f07ef413471..db4dfa5efcc5d 100644 --- 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 index d3411722283cc..1f05534e5c0f8 100644 --- 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<typename T> 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 index 1efd2a5844e88..cfc1a7a6c309f 100644 --- 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<typename T> 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<void(*)()> struct instantiate { }; template<typename T> struct X2 { - typedef instantiate<&X1<int>::member> i; // expected-note{{in instantiation of}} + typedef instantiate<&X1<int>::member> i; // precxx17-note{{in instantiation of}} }; X2<int> x; diff --git a/clang/test/SemaTemplate/instantiation-default-2.cpp b/clang/test/SemaTemplate/instantiation-default-2.cpp index 5a744a0c384a3..99c25000bcb0b 100644 --- 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<typename T, T Value> struct Constant; // expected-note{{template parameter is declared here}} \ -// FIXME: bad location expected-error{{a non-type template parameter cannot have type 'float'}} +template<typename T, T Value> struct Constant; // precxx17-note{{template parameter is declared here}} \ +// FIXME: bad location precxx20-error{{a non-type template parameter cannot have type 'float'}} Constant<int, 5> *c1; @@ -13,6 +15,9 @@ Constant<int*, &x> *c3; Constant<float (*)(int, double), f> *c4; Constant<float (*)(int, double), &f> *c5; -Constant<float (*)(int, int), f> *c6; // expected-error{{non-type template argument of type 'float (int, double)' cannot be converted to a value of type 'float (*)(int, int)'}} +Constant<float (*)(int, int), f> *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<float, 0> *c7; // expected-note{{while substituting}} +Constant<float, 0> *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 index 72c172f001bd2..2db4a51d6cccb 100644 --- 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<typename T, int I, template<typename> 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<typename> class X; @@ -10,7 +14,8 @@ A<int, 0, X> * a1; A<float, 1, X, double> *a2; // expected-error{{too many template arguments for class template 'A'}} A<float, 1> *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 t> class foo {}; diff --git a/clang/test/SemaTemplate/temp_arg_template.cpp b/clang/test/SemaTemplate/temp_arg_template.cpp index 3ab847285ac84..3c2697329212e 100644 --- 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<template<typename T> class X> struct A; // expected-note 2{{previous template template parameter is here}} @@ -42,7 +41,8 @@ A<::N::Z> *a10; // 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 @@ void foo() { namespace CheckDependentNonTypeParamTypes { template<template<typename T, typename U, T v> class X> struct A { void f() { - X<int, void*, 3> x; // expected-error {{does not refer to any declaration}} + X<int, void*, 3> x; // precxx17-error {{does not refer to any declaration}} \ + cxx17-error {{value of type 'int' is not implicitly convertible to 'void *'}} } void g() { X<int, long, 3> x; @@ -123,7 +124,7 @@ namespace CheckDependentNonTypeParamTypes { } }; - template<typename T, typename U, U v> struct B { // expected-note {{parameter}} + template<typename T, typename U, U v> 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 index dc9d00601d486..de2b9b61ebbab 100644 --- 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<class T> struct a { // expected-note {{here}} +template<class T> struct a { // precxx17-note {{here}} T b() { return typename T::x(); } @@ -16,8 +17,8 @@ B c() { // Some extra tests for invalid cases template<class T> struct test2 { T b() { return typename T::a; } }; // expected-error{{expected '(' for function-style cast or type construction}} -template<class T> struct test3 { T b() { return typename a; } }; // expected-error{{expected a qualified name after 'typename'}} -template<class T> 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<class T> 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<class T> 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 index f51d50ac94c42..87fbcd852f498 100644 --- a/clang/unittests/AST/ASTTraverserTest.cpp +++ b/clang/unittests/AST/ASTTraverserTest.cpp @@ -280,7 +280,7 @@ TemplateArgument type int TEST(Traverse, IgnoreUnlessSpelledInSourceVars) { - auto AST = buildASTFromCode(R"cpp( + auto AST = buildASTFromCodeWithArgs(R"cpp( struct String { @@ -346,7 +346,7 @@ void varDeclCtors() { } } -)cpp"); +)cpp", {"-std=c++14"}); { auto FN = @@ -715,7 +715,7 @@ FunctionDecl 'foo' TEST(Traverse, IgnoreUnlessSpelledInSourceReturns) { - auto AST = buildASTFromCode(R"cpp( + auto AST = buildASTFromCodeWithArgs(R"cpp( struct A { @@ -784,7 +784,7 @@ B func12() { 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 index e2e79297e63c2..30acfebc9ee86 100644 --- a/llvm/utils/lit/lit/llvm/config.py +++ b/llvm/utils/lit/lit/llvm/config.py @@ -567,6 +567,32 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[], 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- diff erent-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'. ***\"''' % ( _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits