[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
This commit is contained in:
Fangrui Song 2022-09-04 05:29:32 +00:00
parent 30ceb783e2
commit 83ea47acd7
70 changed files with 391 additions and 251 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -14,6 +14,9 @@ void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
__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);

View File

@ -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

View File

@ -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();

View File

@ -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}}

View File

@ -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}}

View File

@ -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.

View File

@ -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();

View File

@ -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();

View File

@ -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

View File

@ -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'}}

View File

@ -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);

View File

@ -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

View File

@ -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;
}
}

View File

@ -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 {

View File

@ -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 {};

View File

@ -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) {

View File

@ -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(); };

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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]

View File

@ -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;
};

View File

@ -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"

View File

@ -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>

View File

@ -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, ...);

View File

@ -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"

View File

@ -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 @@ public:
};
};
#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'}}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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)

View File

@ -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}}

View File

@ -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) {

View File

@ -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);
}

View File

@ -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}}

View File

@ -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

View File

@ -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.

View File

@ -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}}
}
}

View File

@ -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(); }

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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
};
}

View File

@ -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

View File

@ -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;

View File

@ -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 {

View File

@ -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}}
}
}

View File

@ -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];
}
}

View File

@ -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

View File

@ -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.

View File

@ -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;

View File

@ -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}}
}
}

View File

@ -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}}

View File

@ -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}}

View File

@ -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;

View File

@ -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}}

View File

@ -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 {};

View File

@ -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;
};

View File

@ -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 {

View File

@ -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"),

View File

@ -567,6 +567,32 @@ class LLVMConfig(object):
self.config.substitutions.append(
('%target_itanium_abi_host_triple', ''))
# TODO: Many tests work across many language standards. Before
# https://discourse.llvm.org/t/lit-run-a-run-line-multiple-times-with-different-replacements/64932
# has a solution, provide substitutions to conveniently try every standard with LIT_CLANG_STD_GROUP.
clang_std_group = int(os.environ.get('LIT_CLANG_STD_GROUP', '0'))
clang_std_values = ('98', '11', '14', '17', '20', '2b')
def add_std_cxx(s):
t = s[8:]
if t.endswith('-'):
t += clang_std_values[-1]
l = clang_std_values.index(t[0:2] if t[0:2] != '23' else '2b')
h = clang_std_values.index(t[3:5])
# Let LIT_CLANG_STD_GROUP=0 pick the highest value (likely the most relevant
# standard).
l = h - clang_std_group % (h-l+1)
self.config.substitutions.append((s, '-std=c++' + clang_std_values[l]))
add_std_cxx('%std_cxx98-14')
add_std_cxx('%std_cxx98-')
add_std_cxx('%std_cxx11-14')
add_std_cxx('%std_cxx11-')
add_std_cxx('%std_cxx14-')
add_std_cxx('%std_cxx17-20')
add_std_cxx('%std_cxx17-')
add_std_cxx('%std_cxx20-')
add_std_cxx('%std_cxx23-')
# FIXME: Find nicer way to prohibit this.
def prefer(this, to):
return '''\"*** Do not use '%s' in tests, use '%s'. ***\"''' % (