forked from OSchip/llvm-project
[clang] tests: cleanup, update and add some new ones
This reworks a small set of tests, as preparatory work for implementing P2266. * Run for more standard versions, including c++2b. * Normalize file names and run commands. * Adds some extra tests. New Coroutine tests taken from Aaron Puchert's D68845. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: thakis Differential Revision: https://reviews.llvm.org/D99225
This commit is contained in:
parent
d8bc4de3cf
commit
1819222860
|
@ -1,7 +1,8 @@
|
|||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=expected,cxx20 %s
|
||||
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -verify=expected,cxx11_14_17 %s
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -verify=expected,cxx11_14_17 %s
|
||||
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify=expected,cxx11_14_17 %s
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions -verify=expected,cxx20_2b %s
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=expected,cxx20_2b %s
|
||||
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -verify=expected,cxx11_17 %s
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -verify=expected,cxx11_17 %s
|
||||
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify=expected,cxx11_17 %s
|
||||
|
||||
namespace test_delete_function {
|
||||
struct A1 {
|
||||
|
@ -54,38 +55,38 @@ B2 test4() {
|
|||
namespace test_implicitly_movable_rvalue_ref {
|
||||
struct A1 {
|
||||
A1(A1 &&);
|
||||
A1(const A1 &) = delete; // cxx11_14_17-note {{'A1' has been explicitly marked deleted here}}
|
||||
A1(const A1 &) = delete; // cxx11_17-note {{'A1' has been explicitly marked deleted here}}
|
||||
};
|
||||
A1 test1(A1 &&a) {
|
||||
return a; // cxx11_14_17-error {{call to deleted constructor of 'test_implicitly_movable_rvalue_ref::A1'}}
|
||||
return a; // cxx11_17-error {{call to deleted constructor of 'test_implicitly_movable_rvalue_ref::A1'}}
|
||||
}
|
||||
|
||||
struct A2 {
|
||||
A2(A2 &&);
|
||||
|
||||
private:
|
||||
A2(const A2 &); // cxx11_14_17-note {{declared private here}}
|
||||
A2(const A2 &); // cxx11_17-note {{declared private here}}
|
||||
};
|
||||
A2 test2(A2 &&a) {
|
||||
return a; // cxx11_14_17-error {{calling a private constructor of class 'test_implicitly_movable_rvalue_ref::A2'}}
|
||||
return a; // cxx11_17-error {{calling a private constructor of class 'test_implicitly_movable_rvalue_ref::A2'}}
|
||||
}
|
||||
|
||||
struct B1 {
|
||||
B1(const B1 &);
|
||||
B1(B1 &&) = delete; // cxx20-note {{'B1' has been explicitly marked deleted here}}
|
||||
B1(B1 &&) = delete; // cxx20_2b-note {{'B1' has been explicitly marked deleted here}}
|
||||
};
|
||||
B1 test3(B1 &&b) {
|
||||
return b; // cxx20-error {{call to deleted constructor of 'test_implicitly_movable_rvalue_ref::B1'}}
|
||||
return b; // cxx20_2b-error {{call to deleted constructor of 'test_implicitly_movable_rvalue_ref::B1'}}
|
||||
}
|
||||
|
||||
struct B2 {
|
||||
B2(const B2 &);
|
||||
|
||||
private:
|
||||
B2(B2 &&); // cxx20-note {{declared private here}}
|
||||
B2(B2 &&); // cxx20_2b-note {{declared private here}}
|
||||
};
|
||||
B2 test4(B2 &&b) {
|
||||
return b; // cxx20-error {{calling a private constructor of class 'test_implicitly_movable_rvalue_ref::B2'}}
|
||||
return b; // cxx20_2b-error {{calling a private constructor of class 'test_implicitly_movable_rvalue_ref::B2'}}
|
||||
}
|
||||
} // namespace test_implicitly_movable_rvalue_ref
|
||||
|
||||
|
@ -96,13 +97,14 @@ void func();
|
|||
|
||||
struct A1 {
|
||||
A1(const A1 &);
|
||||
A1(A1 &&) = delete; // cxx20-note {{'A1' has been explicitly marked deleted here}}
|
||||
A1(A1 &&) = delete; // cxx20_2b-note {{'A1' has been explicitly marked deleted here}}
|
||||
// expected-note@-1 {{'A1' has been explicitly marked deleted here}}
|
||||
};
|
||||
void test1() {
|
||||
try {
|
||||
func();
|
||||
} catch (A1 a) {
|
||||
throw a; // cxx20-error {{call to deleted constructor of 'test_throw_parameter::A1'}}
|
||||
throw a; // cxx20_2b-error {{call to deleted constructor of 'test_throw_parameter::A1'}}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,15 +112,21 @@ struct A2 {
|
|||
A2(const A2 &);
|
||||
|
||||
private:
|
||||
A2(A2 &&); // cxx20-note {{declared private here}}
|
||||
A2(A2 &&); // cxx20_2b-note {{declared private here}}
|
||||
};
|
||||
void test2() {
|
||||
try {
|
||||
func();
|
||||
} catch (A2 a) {
|
||||
throw a; // cxx20-error {{calling a private constructor of class 'test_throw_parameter::A2'}}
|
||||
throw a; // cxx20_2b-error {{calling a private constructor of class 'test_throw_parameter::A2'}}
|
||||
}
|
||||
}
|
||||
|
||||
void test3(A1 a) try {
|
||||
func();
|
||||
} catch (...) {
|
||||
throw a; // expected-error {{call to deleted constructor of 'test_throw_parameter::A1'}}
|
||||
}
|
||||
} // namespace test_throw_parameter
|
||||
|
||||
// In C++20, during the first overload resolution, the selected function no
|
||||
|
@ -128,42 +136,42 @@ class C {};
|
|||
|
||||
struct A1 {
|
||||
operator C() &&;
|
||||
operator C() const & = delete; // cxx11_14_17-note {{'operator C' has been explicitly marked deleted here}}
|
||||
operator C() const & = delete; // cxx11_17-note {{'operator C' has been explicitly marked deleted here}}
|
||||
};
|
||||
C test1() {
|
||||
A1 a;
|
||||
return a; // cxx11_14_17-error {{conversion function from 'test_non_ctor_conversion::A1' to 'test_non_ctor_conversion::C' invokes a deleted function}}
|
||||
return a; // cxx11_17-error {{conversion function from 'test_non_ctor_conversion::A1' to 'test_non_ctor_conversion::C' invokes a deleted function}}
|
||||
}
|
||||
|
||||
struct A2 {
|
||||
operator C() &&;
|
||||
|
||||
private:
|
||||
operator C() const &; // cxx11_14_17-note {{declared private here}}
|
||||
operator C() const &; // cxx11_17-note {{declared private here}}
|
||||
};
|
||||
C test2() {
|
||||
A2 a;
|
||||
return a; // cxx11_14_17-error {{'operator C' is a private member of 'test_non_ctor_conversion::A2'}}
|
||||
return a; // cxx11_17-error {{'operator C' is a private member of 'test_non_ctor_conversion::A2'}}
|
||||
}
|
||||
|
||||
struct B1 {
|
||||
operator C() const &;
|
||||
operator C() && = delete; // cxx20-note {{'operator C' has been explicitly marked deleted here}}
|
||||
operator C() && = delete; // cxx20_2b-note {{'operator C' has been explicitly marked deleted here}}
|
||||
};
|
||||
C test3() {
|
||||
B1 b;
|
||||
return b; // cxx20-error {{conversion function from 'test_non_ctor_conversion::B1' to 'test_non_ctor_conversion::C' invokes a deleted function}}
|
||||
return b; // cxx20_2b-error {{conversion function from 'test_non_ctor_conversion::B1' to 'test_non_ctor_conversion::C' invokes a deleted function}}
|
||||
}
|
||||
|
||||
struct B2 {
|
||||
operator C() const &;
|
||||
|
||||
private:
|
||||
operator C() &&; // cxx20-note {{declared private here}}
|
||||
operator C() &&; // cxx20_2b-note {{declared private here}}
|
||||
};
|
||||
C test4() {
|
||||
B2 b;
|
||||
return b; // cxx20-error {{'operator C' is a private member of 'test_non_ctor_conversion::B2'}}
|
||||
return b; // cxx20_2b-error {{'operator C' is a private member of 'test_non_ctor_conversion::B2'}}
|
||||
}
|
||||
} // namespace test_non_ctor_conversion
|
||||
|
||||
|
@ -182,35 +190,35 @@ struct NeedRvalueRef {
|
|||
NeedRvalueRef(B2 &&);
|
||||
};
|
||||
struct NeedValue {
|
||||
NeedValue(A1); // cxx11_14_17-note 2 {{passing argument to parameter here}}
|
||||
NeedValue(A1); // cxx11_17-note 2 {{passing argument to parameter here}}
|
||||
NeedValue(A2);
|
||||
NeedValue(B1); // cxx20-note 2 {{passing argument to parameter here}}
|
||||
NeedValue(B1); // cxx20_2b-note 2 {{passing argument to parameter here}}
|
||||
NeedValue(B2);
|
||||
};
|
||||
|
||||
struct A1 {
|
||||
A1();
|
||||
A1(A1 &&);
|
||||
A1(const A1 &) = delete; // cxx11_14_17-note 3 {{'A1' has been explicitly marked deleted here}}
|
||||
A1(const A1 &) = delete; // cxx11_17-note 3 {{'A1' has been explicitly marked deleted here}}
|
||||
};
|
||||
NeedValue test_1_1() {
|
||||
// not rvalue reference
|
||||
// same type
|
||||
A1 a;
|
||||
return a; // cxx11_14_17-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::A1'}}
|
||||
return a; // cxx11_17-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::A1'}}
|
||||
}
|
||||
class DerivedA1 : public A1 {};
|
||||
A1 test_1_2() {
|
||||
// rvalue reference
|
||||
// not same type
|
||||
DerivedA1 a;
|
||||
return a; // cxx11_14_17-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::A1'}}
|
||||
return a; // cxx11_17-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::A1'}}
|
||||
}
|
||||
NeedValue test_1_3() {
|
||||
// not rvalue reference
|
||||
// not same type
|
||||
DerivedA1 a;
|
||||
return a; // cxx11_14_17-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::A1'}}
|
||||
return a; // cxx11_17-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::A1'}}
|
||||
}
|
||||
|
||||
struct A2 {
|
||||
|
@ -218,51 +226,51 @@ struct A2 {
|
|||
A2(A2 &&);
|
||||
|
||||
private:
|
||||
A2(const A2 &); // cxx11_14_17-note 3 {{declared private here}}
|
||||
A2(const A2 &); // cxx11_17-note 3 {{declared private here}}
|
||||
};
|
||||
NeedValue test_2_1() {
|
||||
// not rvalue reference
|
||||
// same type
|
||||
A2 a;
|
||||
return a; // cxx11_14_17-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::A2'}}
|
||||
return a; // cxx11_17-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::A2'}}
|
||||
}
|
||||
class DerivedA2 : public A2 {};
|
||||
A2 test_2_2() {
|
||||
// rvalue reference
|
||||
// not same type
|
||||
DerivedA2 a;
|
||||
return a; // cxx11_14_17-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::A2'}}
|
||||
return a; // cxx11_17-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::A2'}}
|
||||
}
|
||||
NeedValue test_2_3() {
|
||||
// not rvalue reference
|
||||
// not same type
|
||||
DerivedA2 a;
|
||||
return a; // cxx11_14_17-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::A2'}}
|
||||
return a; // cxx11_17-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::A2'}}
|
||||
}
|
||||
|
||||
struct B1 {
|
||||
B1();
|
||||
B1(const B1 &);
|
||||
B1(B1 &&) = delete; // cxx20-note 3 {{'B1' has been explicitly marked deleted here}}
|
||||
B1(B1 &&) = delete; // cxx20_2b-note 3 {{'B1' has been explicitly marked deleted here}}
|
||||
};
|
||||
NeedValue test_3_1() {
|
||||
// not rvalue reference
|
||||
// same type
|
||||
B1 b;
|
||||
return b; // cxx20-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::B1'}}
|
||||
return b; // cxx20_2b-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::B1'}}
|
||||
}
|
||||
class DerivedB1 : public B1 {};
|
||||
B1 test_3_2() {
|
||||
// rvalue reference
|
||||
// not same type
|
||||
DerivedB1 b;
|
||||
return b; // cxx20-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::B1'}}
|
||||
return b; // cxx20_2b-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::B1'}}
|
||||
}
|
||||
NeedValue test_3_3() {
|
||||
// not rvalue reference
|
||||
// not same type
|
||||
DerivedB1 b;
|
||||
return b; // cxx20-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::B1'}}
|
||||
return b; // cxx20_2b-error {{call to deleted constructor of 'test_ctor_param_rvalue_ref::B1'}}
|
||||
}
|
||||
|
||||
struct B2 {
|
||||
|
@ -270,26 +278,26 @@ struct B2 {
|
|||
B2(const B2 &);
|
||||
|
||||
private:
|
||||
B2(B2 &&); // cxx20-note 3 {{declared private here}}
|
||||
B2(B2 &&); // cxx20_2b-note 3 {{declared private here}}
|
||||
};
|
||||
NeedValue test_4_1() {
|
||||
// not rvalue reference
|
||||
// same type
|
||||
B2 b;
|
||||
return b; // cxx20-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::B2'}}
|
||||
return b; // cxx20_2b-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::B2'}}
|
||||
}
|
||||
class DerivedB2 : public B2 {};
|
||||
B2 test_4_2() {
|
||||
// rvalue reference
|
||||
// not same type
|
||||
DerivedB2 b;
|
||||
return b; // cxx20-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::B2'}}
|
||||
return b; // cxx20_2b-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::B2'}}
|
||||
}
|
||||
NeedValue test_4_3() {
|
||||
// not rvalue reference
|
||||
// not same type
|
||||
DerivedB2 b;
|
||||
return b; // cxx20-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::B2'}}
|
||||
return b; // cxx20_2b-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::B2'}}
|
||||
}
|
||||
} // namespace test_ctor_param_rvalue_ref
|
||||
|
||||
|
@ -298,21 +306,21 @@ namespace test_lvalue_ref_is_not_moved_from {
|
|||
struct Target {};
|
||||
// expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable}}
|
||||
// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
|
||||
// cxx11_14_17-note@-3 {{candidate constructor (the implicit copy constructor) not viable}}
|
||||
// cxx11_14_17-note@-4 {{candidate constructor (the implicit move constructor) not viable}}
|
||||
// cxx11_17-note@-3 {{candidate constructor (the implicit copy constructor) not viable}}
|
||||
// cxx11_17-note@-4 {{candidate constructor (the implicit move constructor) not viable}}
|
||||
|
||||
struct CopyOnly {
|
||||
CopyOnly(CopyOnly&&) = delete; // cxx20-note {{has been explicitly marked deleted here}}
|
||||
CopyOnly(CopyOnly&&) = delete; // cxx20_2b-note {{has been explicitly marked deleted here}}
|
||||
CopyOnly(CopyOnly&);
|
||||
operator Target() && = delete; // cxx20-note {{has been explicitly marked deleted here}}
|
||||
operator Target() && = delete; // cxx20_2b-note {{has been explicitly marked deleted here}}
|
||||
operator Target() &;
|
||||
};
|
||||
|
||||
struct MoveOnly {
|
||||
MoveOnly(MoveOnly&&); // expected-note {{copy constructor is implicitly deleted because}}
|
||||
// cxx11_14_17-note@-1 {{copy constructor is implicitly deleted because}}
|
||||
// cxx11_17-note@-1 {{copy constructor is implicitly deleted because}}
|
||||
operator Target() &&; // expected-note {{candidate function not viable}}
|
||||
// cxx11_14_17-note@-1 {{candidate function not viable}}
|
||||
// cxx11_17-note@-1 {{candidate function not viable}}
|
||||
};
|
||||
|
||||
extern CopyOnly copyonly;
|
||||
|
@ -325,7 +333,7 @@ CopyOnly t1() {
|
|||
|
||||
CopyOnly t2() {
|
||||
CopyOnly&& r = static_cast<CopyOnly&&>(copyonly);
|
||||
return r; // cxx20-error {{call to deleted constructor}}
|
||||
return r; // cxx20_2b-error {{call to deleted constructor}}
|
||||
}
|
||||
|
||||
MoveOnly t3() {
|
||||
|
@ -335,7 +343,7 @@ MoveOnly t3() {
|
|||
|
||||
MoveOnly t4() {
|
||||
MoveOnly&& r = static_cast<MoveOnly&&>(moveonly);
|
||||
return r; // cxx11_14_17-error {{call to implicitly-deleted copy constructor}}
|
||||
return r; // cxx11_17-error {{call to implicitly-deleted copy constructor}}
|
||||
}
|
||||
|
||||
Target t5() {
|
||||
|
@ -345,7 +353,7 @@ Target t5() {
|
|||
|
||||
Target t6() {
|
||||
CopyOnly&& r = static_cast<CopyOnly&&>(copyonly);
|
||||
return r; // cxx20-error {{invokes a deleted function}}
|
||||
return r; // cxx20_2b-error {{invokes a deleted function}}
|
||||
}
|
||||
|
||||
Target t7() {
|
||||
|
@ -355,7 +363,7 @@ Target t7() {
|
|||
|
||||
Target t8() {
|
||||
MoveOnly&& r = static_cast<MoveOnly&&>(moveonly);
|
||||
return r; // cxx11_14_17-error {{no viable conversion}}
|
||||
return r; // cxx11_17-error {{no viable conversion}}
|
||||
}
|
||||
|
||||
} // namespace test_lvalue_ref_is_not_moved_from
|
||||
|
@ -397,3 +405,46 @@ Target t4() {
|
|||
}
|
||||
|
||||
} // namespace test_rvalue_ref_to_nonobject
|
||||
|
||||
namespace test_simpler_implicit_move {
|
||||
|
||||
struct CopyOnly {
|
||||
CopyOnly();
|
||||
CopyOnly(CopyOnly &);
|
||||
};
|
||||
struct MoveOnly {
|
||||
MoveOnly();
|
||||
MoveOnly(MoveOnly &&);
|
||||
};
|
||||
MoveOnly &&rref();
|
||||
|
||||
MoveOnly &&test1(MoveOnly &&w) {
|
||||
return w; // expected-error {{cannot bind to lvalue of type}}
|
||||
}
|
||||
|
||||
CopyOnly test2(bool b) {
|
||||
static CopyOnly w1;
|
||||
CopyOnly w2;
|
||||
if (b) {
|
||||
return w1;
|
||||
} else {
|
||||
return w2;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> T &&test3(T &&x) { return x; } // expected-error {{cannot bind to lvalue of type}}
|
||||
template MoveOnly& test3<MoveOnly&>(MoveOnly&);
|
||||
template MoveOnly&& test3<MoveOnly>(MoveOnly&&); // expected-note {{in instantiation of function template specialization}}
|
||||
|
||||
MoveOnly &&test4() {
|
||||
MoveOnly &&x = rref();
|
||||
return x; // expected-error {{cannot bind to lvalue of type}}
|
||||
}
|
||||
|
||||
void test5() try {
|
||||
CopyOnly x;
|
||||
throw x;
|
||||
} catch (...) {
|
||||
}
|
||||
|
||||
} // namespace test_simpler_implicit_move
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// RUN: %clang_cc1 -verify -std=c++1y %s
|
||||
// RUN: %clang_cc1 -verify -std=c++2b -verify %s
|
||||
// RUN: %clang_cc1 -verify -std=c++20 -verify %s
|
||||
// RUN: %clang_cc1 -verify -std=c++14 -verify %s
|
||||
|
||||
namespace std {
|
||||
template<typename T> struct initializer_list {
|
|
@ -1,7 +1,9 @@
|
|||
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
|
||||
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
|
||||
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
|
||||
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
|
||||
// RUN: %clang_cc1 -std=c++2b -verify=expected,cxx20_2b -triple %itanium_abi_triple %s -fexceptions -fcxx-exceptions -pedantic-errors
|
||||
// RUN: %clang_cc1 -std=c++20 -verify=expected,cxx20_2b -triple %itanium_abi_triple %s -fexceptions -fcxx-exceptions -pedantic-errors
|
||||
// RUN: %clang_cc1 -std=c++17 -verify=expected,cxx98_17 -triple %itanium_abi_triple %s -fexceptions -fcxx-exceptions -pedantic-errors
|
||||
// RUN: %clang_cc1 -std=c++14 -verify=expected,cxx98_17 -triple %itanium_abi_triple %s -fexceptions -fcxx-exceptions -pedantic-errors
|
||||
// RUN: %clang_cc1 -std=c++11 -verify=expected,cxx98_17 -triple %itanium_abi_triple %s -fexceptions -fcxx-exceptions -pedantic-errors
|
||||
// RUN: %clang_cc1 -std=c++98 -verify=expected,cxx98_17 -triple %itanium_abi_triple %s -fexceptions -fcxx-exceptions -pedantic-errors
|
||||
|
||||
namespace dr300 { // dr300: yes
|
||||
template<typename R, typename A> void f(R (&)(A)) {}
|
||||
|
@ -18,8 +20,8 @@ namespace dr301 { // dr301: yes
|
|||
void f() {
|
||||
bool a = (void(*)(S, S))operator+<S> <
|
||||
(void(*)(S, S))operator+<S>;
|
||||
bool b = (void(*)(S, S))operator- <
|
||||
(void(*)(S, S))operator-;
|
||||
bool b = (void(*)(S, S))operator- < // cxx20_2b-note {{to match this '<'}}
|
||||
(void(*)(S, S))operator-; // cxx20_2b-error {{expected '>'}}
|
||||
bool c = (void(*)(S, S))operator+ < // expected-note {{to match this '<'}}
|
||||
(void(*)(S, S))operator-; // expected-error {{expected '>'}}
|
||||
}
|
||||
|
@ -439,8 +441,10 @@ namespace dr331 { // dr331: yes
|
|||
|
||||
namespace dr332 { // dr332: dup 577
|
||||
void f(volatile void); // expected-error {{'void' as parameter must not have type qualifiers}}
|
||||
// cxx20_2b-warning@-1 {{volatile-qualified parameter type 'volatile void' is deprecated}}
|
||||
void g(const void); // expected-error {{'void' as parameter must not have type qualifiers}}
|
||||
void h(int n, volatile void); // expected-error {{'void' must be the first and only parameter}}
|
||||
// cxx20_2b-warning@-1 {{volatile-qualified parameter type 'volatile void' is deprecated}}
|
||||
}
|
||||
|
||||
namespace dr333 { // dr333: yes
|
||||
|
@ -910,10 +914,13 @@ namespace dr367 { // dr367: yes
|
|||
namespace dr368 { // dr368: yes
|
||||
template<typename T, T> struct S {}; // expected-note {{here}}
|
||||
template<typename T> int f(S<T, T()> *); // expected-error {{function type}}
|
||||
template<typename T> int g(S<T, (T())> *); // expected-note {{type 'dr368::X'}}
|
||||
template<typename T> int g(S<T, true ? T() : T()> *); // expected-note {{type 'dr368::X'}}
|
||||
template<typename T> int g(S<T, (T())> *); // cxx98_17-note {{type 'dr368::X'}}
|
||||
// cxx20_2b-note@-1 {{candidate function [with T = dr368::X]}}
|
||||
template<typename T> int g(S<T, true ? T() : T()> *); // cxx98_17-note {{type 'dr368::X'}}
|
||||
// cxx20_2b-note@-1 {{candidate function [with T = dr368::X]}}
|
||||
struct X {};
|
||||
int n = g<X>(0); // expected-error {{no matching}}
|
||||
int n = g<X>(0); // cxx98_17-error {{no matching}}
|
||||
// cxx20_2b-error@-1 {{call to 'g' is ambiguous}}
|
||||
}
|
||||
|
||||
// dr370: na
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
|
||||
|
||||
int a;
|
||||
int &b = [] (int &r) -> decltype(auto) { return r; } (a);
|
||||
|
@ -8,7 +10,6 @@ int &e = [] (int &r) -> auto { return r; } (a); // expected-error {{cannot bind
|
|||
int &f = [] (int r) -> decltype(auto) { return r; } (a); // expected-error {{cannot bind to a temporary}}
|
||||
int &g = [] (int r) -> decltype(auto) { return (r); } (a); // expected-warning {{reference to stack}}
|
||||
|
||||
|
||||
int test_explicit_auto_return()
|
||||
{
|
||||
struct X {};
|
||||
|
@ -66,4 +67,4 @@ int test_conditional_in_return() {
|
|||
// FIXME: this test causes a recursive limit - need to error more gracefully.
|
||||
//Fac(Fac, 3);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++2b -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++20 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -fsyntax-only -verify %s
|
||||
class X {
|
||||
X(const X&);
|
|
@ -1,4 +1,8 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
struct A {
|
||||
template <class T> operator T*();
|
||||
};
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
// RUN: %clang_cc1 -std=c++20 -fblocks -Wno-return-stack-address -triple x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - %s | FileCheck %s
|
||||
|
||||
struct X {
|
||||
X();
|
||||
X(const X&);
|
||||
X(X&&);
|
||||
};
|
||||
|
||||
#define L(A, B, C) void l##A() { \
|
||||
auto t = []<class T = X>() -> C { \
|
||||
T t; \
|
||||
return B; \
|
||||
}(); \
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2l1v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
L(1, t, X);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2l2v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
L(2, t, X&);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2l3v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1EOS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
L(3, t, T);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2l4v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
L(4, t, T&);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2l5v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1EOS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
L(5, t, auto);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2l6v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
L(6, t, auto&);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2l7v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1EOS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
L(7, t, decltype(auto));
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2l8v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
L(8, (t), decltype(auto));
|
||||
|
||||
#undef L
|
||||
|
||||
#define F(A, B, C) template<class T = X> static inline auto tf##A() -> C { \
|
||||
T t; \
|
||||
return B; \
|
||||
} \
|
||||
void f##A() { auto t = tf##A(); } \
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2f1v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
F(1, t, X);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2f2v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
F(2, t, X&);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2f3v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
F(3, t, T);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2f4v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
F(4, t, T&);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2f5v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1EOS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
F(5, t, auto);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2f6v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
F(6, t, auto&);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2f7v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1EOS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
F(7, t, decltype(auto));
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2f8v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
F(8, (t), decltype(auto));
|
||||
|
||||
#undef F
|
||||
|
||||
#define B(A, B) void b##A() { \
|
||||
auto t = []<class T = X>() { return ^ B () { \
|
||||
T t; \
|
||||
return t; \
|
||||
}; }()(); \
|
||||
}
|
||||
|
||||
//B(1, X); // Uncomment this line at your own peril ;)
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2b2v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
B(2, X&);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2b3v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1EOS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
B(3, T);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2b4v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
B(4, T&);
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_Z2b5v
|
||||
// CHECK: call {{.*}} @_ZN1XC1Ev
|
||||
// CHECK-NEXT: call {{.*}} @_ZN1XC1EOS_
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: call void @llvm.lifetime.end
|
||||
// CHECK-NEXT: ret void
|
||||
B(5, );
|
||||
|
||||
#undef B
|
|
@ -1,8 +1,9 @@
|
|||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=cxx20 %s
|
||||
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -verify=cxx11_14_17 %s
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -verify=cxx11_14_17 %s
|
||||
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify=cxx11_14_17 %s
|
||||
// cxx20-no-diagnostics
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions -verify=cxx20_2b %s
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=cxx20_2b %s
|
||||
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -verify=cxx11_17 %s
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -verify=cxx11_17 %s
|
||||
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify=cxx11_17 %s
|
||||
// cxx20_2b-no-diagnostics
|
||||
|
||||
// Throwing
|
||||
namespace test_throwing {
|
||||
|
@ -22,13 +23,13 @@ namespace test_non_constructor_conversion {
|
|||
class Widget {};
|
||||
|
||||
struct To {
|
||||
operator Widget() const & = delete; // cxx11_14_17-note {{'operator Widget' has been explicitly marked deleted here}}
|
||||
operator Widget() const & = delete; // cxx11_17-note {{'operator Widget' has been explicitly marked deleted here}}
|
||||
operator Widget() &&;
|
||||
};
|
||||
|
||||
Widget nine() {
|
||||
To t;
|
||||
return t; // cxx11_14_17-error {{conversion function from 'test_non_constructor_conversion::To' to 'test_non_constructor_conversion::Widget' invokes a deleted function}}
|
||||
return t; // cxx11_17-error {{conversion function from 'test_non_constructor_conversion::To' to 'test_non_constructor_conversion::Widget' invokes a deleted function}}
|
||||
}
|
||||
} // namespace test_non_constructor_conversion
|
||||
|
||||
|
@ -38,16 +39,16 @@ class Widget {
|
|||
public:
|
||||
Widget();
|
||||
Widget(Widget &&);
|
||||
Widget(const Widget &) = delete; // cxx11_14_17-note {{'Widget' has been explicitly marked deleted here}}
|
||||
Widget(const Widget &) = delete; // cxx11_17-note {{'Widget' has been explicitly marked deleted here}}
|
||||
};
|
||||
|
||||
struct Fowl {
|
||||
Fowl(Widget); // cxx11_14_17-note {{passing argument to parameter here}}
|
||||
Fowl(Widget); // cxx11_17-note {{passing argument to parameter here}}
|
||||
};
|
||||
|
||||
Fowl eleven() {
|
||||
Widget w;
|
||||
return w; // cxx11_14_17-error {{call to deleted constructor of 'test_by_value_sinks::Widget'}}
|
||||
return w; // cxx11_17-error {{call to deleted constructor of 'test_by_value_sinks::Widget'}}
|
||||
}
|
||||
} // namespace test_by_value_sinks
|
||||
|
||||
|
@ -57,13 +58,13 @@ class Base {
|
|||
public:
|
||||
Base();
|
||||
Base(Base &&);
|
||||
Base(Base const &) = delete; // cxx11_14_17-note {{'Base' has been explicitly marked deleted here}}
|
||||
Base(Base const &) = delete; // cxx11_17-note {{'Base' has been explicitly marked deleted here}}
|
||||
};
|
||||
|
||||
class Derived : public Base {};
|
||||
|
||||
Base thirteen() {
|
||||
Derived result;
|
||||
return result; // cxx11_14_17-error {{call to deleted constructor of 'test_slicing::Base'}}
|
||||
return result; // cxx11_17-error {{call to deleted constructor of 'test_slicing::Base'}}
|
||||
}
|
||||
} // namespace test_slicing
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
// RUN: %clang_cc1 -triple x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array -Wno-c99-designator -fsyntax-only -fcxx-exceptions -verify -std=c++11 -pedantic %s -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx20_2b -triple x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array -Wno-c99-designator -fcxx-exceptions -pedantic %s -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx20_2b -triple x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array -Wno-c99-designator -fcxx-exceptions -pedantic %s -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion
|
||||
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx11 -triple x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array -Wno-c99-designator -fcxx-exceptions -pedantic %s -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion
|
||||
|
||||
namespace StaticAssertFoldTest {
|
||||
|
||||
int x;
|
||||
static_assert(++x, "test"); // expected-error {{not an integral constant expression}}
|
||||
// cxx20_2b-note@-1 {{cannot modify an object that is visible outside that expression}}
|
||||
static_assert(false, "test"); // expected-error {{test}}
|
||||
|
||||
}
|
||||
|
@ -318,13 +321,13 @@ static_assert(&x < &x, "false"); // expected-error {{false}}
|
|||
static_assert(&x > &x, "false"); // expected-error {{false}}
|
||||
|
||||
constexpr S* sptr = &s;
|
||||
constexpr bool dyncast = sptr == dynamic_cast<S*>(sptr); // expected-error {{constant expression}} expected-note {{dynamic_cast}}
|
||||
constexpr bool dyncast = sptr == dynamic_cast<S*>(sptr); // cxx11-error {{constant expression}} cxx11-note {{dynamic_cast}}
|
||||
|
||||
struct U {};
|
||||
struct Str {
|
||||
int a : dynamic_cast<S*>(sptr) == dynamic_cast<S*>(sptr); // \
|
||||
expected-warning {{not an integral constant expression}} \
|
||||
expected-note {{dynamic_cast is not allowed in a constant expression}}
|
||||
cxx11-warning {{not an integral constant expression}} \
|
||||
cxx11-note {{dynamic_cast is not allowed in a constant expression}}
|
||||
int b : reinterpret_cast<S*>(sptr) == reinterpret_cast<S*>(sptr); // \
|
||||
expected-warning {{not an integral constant expression}} \
|
||||
expected-note {{reinterpret_cast is not allowed in a constant expression}}
|
||||
|
@ -348,6 +351,7 @@ struct Str {
|
|||
extern char externalvar[];
|
||||
constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL; // expected-error {{must be initialized by a constant expression}} expected-note {{reinterpret_cast}}
|
||||
constexpr bool litaddress = "foo" == "foo"; // expected-error {{must be initialized by a constant expression}}
|
||||
// cxx20_2b-warning@-1 {{comparison between two arrays is deprecated}}
|
||||
static_assert(0 != "foo", "");
|
||||
|
||||
}
|
||||
|
@ -387,7 +391,7 @@ constexpr B &&b4 = ((1, 2), 3, 4, B { {10}, {{20}} });
|
|||
static_assert(&b4 != &b2, "");
|
||||
|
||||
// Proposed DR: copy-elision doesn't trigger lifetime extension.
|
||||
// expected-warning@+1 2{{temporary whose address is used as value of local variable 'b5' will be destroyed at the end of the full-expression}}
|
||||
// cxx11-warning@+1 2{{temporary whose address is used as value of local variable 'b5' will be destroyed at the end of the full-expression}}
|
||||
constexpr B b5 = B{ {0}, {0} }; // expected-error {{constant expression}} expected-note {{reference to temporary}} expected-note {{here}}
|
||||
|
||||
namespace NestedNonStatic {
|
||||
|
@ -397,8 +401,8 @@ namespace NestedNonStatic {
|
|||
struct A { int &&r; };
|
||||
struct B { A &&a; };
|
||||
constexpr B a = { A{0} }; // ok
|
||||
// expected-warning@+1 {{temporary bound to reference member of local variable 'b' will be destroyed at the end of the full-expression}}
|
||||
constexpr B b = { A(A{0}) }; // expected-error {{constant expression}} expected-note {{reference to temporary}} expected-note {{here}}
|
||||
// cxx11-warning@+1 {{temporary bound to reference member of local variable 'b' will be destroyed at the end of the full-expression}}
|
||||
constexpr B b = { A(A{0}) }; // cxx11-error {{constant expression}} cxx11-note {{reference to temporary}} cxx11-note {{here}}
|
||||
}
|
||||
|
||||
namespace FakeInitList {
|
||||
|
@ -1637,7 +1641,7 @@ namespace InvalidClasses {
|
|||
|
||||
namespace NamespaceAlias {
|
||||
constexpr int f() {
|
||||
namespace NS = NamespaceAlias; // expected-warning {{use of this statement in a constexpr function is a C++14 extension}}
|
||||
namespace NS = NamespaceAlias; // cxx11-warning {{use of this statement in a constexpr function is a C++14 extension}}
|
||||
return &NS::f != nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -1737,7 +1741,7 @@ namespace TLS {
|
|||
}
|
||||
|
||||
namespace Void {
|
||||
constexpr void f() { return; } // expected-error{{constexpr function's return type 'void' is not a literal type}}
|
||||
constexpr void f() { return; } // cxx11-error{{constexpr function's return type 'void' is not a literal type}}
|
||||
|
||||
void assert_failed(const char *msg, const char *file, int line); // expected-note {{declared here}}
|
||||
#define ASSERT(expr) ((expr) ? static_cast<void>(0) : assert_failed(#expr, __FILE__, __LINE__))
|
||||
|
@ -1759,11 +1763,12 @@ namespace std { struct type_info; }
|
|||
namespace TypeId {
|
||||
struct A { virtual ~A(); };
|
||||
A f();
|
||||
A &g();
|
||||
A &g(); // cxx20_2b-note {{declared here}}
|
||||
constexpr auto &x = typeid(f());
|
||||
constexpr auto &y = typeid(g()); // expected-error{{constant expression}} \
|
||||
// expected-note{{typeid applied to expression of polymorphic type 'TypeId::A' is not allowed in a constant expression}} \
|
||||
// expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}}
|
||||
constexpr auto &y = typeid(g()); // expected-error{{constant expression}}
|
||||
// cxx11-note@-1 {{typeid applied to expression of polymorphic type 'TypeId::A' is not allowed in a constant expression}}
|
||||
// expected-warning@-2 {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}}
|
||||
// cxx20_2b-note@-3 {{non-constexpr function 'g' cannot be used in a constant expression}}
|
||||
}
|
||||
|
||||
namespace PR14203 {
|
||||
|
@ -1893,18 +1898,21 @@ namespace VirtualFromBase {
|
|||
template <typename T> struct X : T {
|
||||
constexpr X() {}
|
||||
double d = 0.0;
|
||||
constexpr int f() { return sizeof(T); } // expected-warning {{will not be implicitly 'const' in C++14}}
|
||||
constexpr int f() { return sizeof(T); } // cxx11-warning {{will not be implicitly 'const' in C++14}}
|
||||
};
|
||||
|
||||
// Virtual f(), not OK.
|
||||
constexpr X<X<S1>> xxs1;
|
||||
constexpr X<S1> *p = const_cast<X<X<S1>>*>(&xxs1);
|
||||
static_assert(p->f() == sizeof(X<S1>), ""); // expected-error {{constant expression}} expected-note {{virtual function}}
|
||||
static_assert(p->f() == sizeof(X<S1>), "");
|
||||
// cxx11-error@-1 {{not an integral constant expression}}
|
||||
// cxx11-note@-2 {{call to virtual function}}
|
||||
// cxx20_2b-error@-3 {{static_assert failed}}
|
||||
|
||||
// Non-virtual f(), OK.
|
||||
constexpr X<X<S2>> xxs2;
|
||||
constexpr X<S2> *q = const_cast<X<X<S2>>*>(&xxs2);
|
||||
static_assert(q->f() == sizeof(S2), "");
|
||||
static_assert(q->f() == sizeof(S2), ""); // cxx20_2b-error {{static_assert failed}}
|
||||
}
|
||||
|
||||
namespace ConstexprConstructorRecovery {
|
||||
|
@ -1917,10 +1925,10 @@ namespace ConstexprConstructorRecovery {
|
|||
};
|
||||
constexpr X() noexcept {};
|
||||
protected:
|
||||
E val{0}; // expected-error {{cannot initialize a member subobject of type 'ConstexprConstructorRecovery::X::E' with an rvalue of type 'int'}} expected-note {{here}}
|
||||
E val{0}; // cxx11-error {{cannot initialize a member subobject of type 'ConstexprConstructorRecovery::X::E' with an rvalue of type 'int'}} cxx11-note {{here}}
|
||||
};
|
||||
// FIXME: We should avoid issuing this follow-on diagnostic.
|
||||
constexpr X x{}; // expected-error {{constant expression}} expected-note {{not initialized}}
|
||||
constexpr X x{}; // cxx11-error {{constant expression}} cxx11-note {{not initialized}}
|
||||
}
|
||||
|
||||
namespace Lifetime {
|
||||
|
@ -2198,7 +2206,7 @@ namespace PR21859 {
|
|||
|
||||
struct InvalidRedef {
|
||||
int f; // expected-note{{previous definition is here}}
|
||||
constexpr int f(void); // expected-error{{redefinition of 'f'}} expected-warning{{will not be implicitly 'const'}}
|
||||
constexpr int f(void); // expected-error{{redefinition of 'f'}} cxx11-warning{{will not be implicitly 'const'}}
|
||||
};
|
||||
|
||||
namespace PR17938 {
|
||||
|
@ -2243,21 +2251,23 @@ namespace InheritedCtor {
|
|||
constexpr C c(0);
|
||||
|
||||
struct D : A {
|
||||
using A::A; // expected-note {{here}}
|
||||
using A::A; // cxx11-note {{here}}
|
||||
struct { // expected-warning {{extension}}
|
||||
union { // expected-warning {{extension}}
|
||||
int n;
|
||||
};
|
||||
};
|
||||
};
|
||||
constexpr D d(0); // expected-error {{constant expression}} expected-note {{derived class}}
|
||||
constexpr D d(0); // cxx11-error {{constant expression}} cxx11-note {{derived class}}
|
||||
|
||||
struct E : virtual A { using A::A; }; // expected-note {{here}}
|
||||
// cxx20_2b-note@-1 {{struct with virtual base class is not a literal type}}
|
||||
// We wrap a function around this to avoid implicit zero-initialization
|
||||
// happening first; the zero-initialization step would produce the same
|
||||
// error and defeat the point of this test.
|
||||
void f() {
|
||||
constexpr E e(0); // expected-error {{constant expression}} expected-note {{derived class}}
|
||||
constexpr E e(0); // cxx11-error {{constant expression}} cxx11-note {{derived class}}
|
||||
// cxx20_2b-error@-1 {{constexpr variable cannot have non-literal type}}
|
||||
}
|
||||
// FIXME: This produces a note with no source location.
|
||||
//constexpr E e(0);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// RUN: %clang_cc1 -std=c++1y -verify %s -fcxx-exceptions -triple=x86_64-linux-gnu
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx20_2b %s -fcxx-exceptions -triple=x86_64-linux-gnu
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx20_2b %s -fcxx-exceptions -triple=x86_64-linux-gnu
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=expected,cxx14 %s -fcxx-exceptions -triple=x86_64-linux-gnu
|
||||
|
||||
struct S {
|
||||
// dummy ctor to make this a literal type
|
||||
|
@ -225,6 +227,7 @@ namespace subobject {
|
|||
// expected-note@-2 {{assignment to member 'c' of union with active member 'n'}}
|
||||
}
|
||||
constexpr bool check(D &d) { return d.c.a.y == 3; }
|
||||
// cxx20_2b-note@-1 {{read of member 'y' of union with active member 'x'}}
|
||||
|
||||
constexpr bool g() { D d; f(d); return d.c.a.y == 3; }
|
||||
static_assert(g(), "");
|
||||
|
@ -236,7 +239,8 @@ namespace subobject {
|
|||
constexpr bool i() { D d(0); f(d); return check(d); } // expected-note {{in call}}
|
||||
static_assert(i(), ""); // expected-error {{constant expression}} expected-note {{in call}}
|
||||
|
||||
constexpr bool j() { D d; d.c.a.x = 3; return check(d); } // expected-note {{assignment to member 'x' of union with active member 'y'}}
|
||||
constexpr bool j() { D d; d.c.a.x = 3; return check(d); } // cxx14-note {{assignment to member 'x' of union with active member 'y'}}
|
||||
// cxx20_2b-note@-1 {{in call to 'check(d)'}}
|
||||
static_assert(j(), ""); // expected-error {{constant expression}} expected-note {{in call}}
|
||||
}
|
||||
|
||||
|
@ -285,8 +289,12 @@ namespace incdec {
|
|||
static_assert(--ref<short>(0x8000) == 0x7fff, "");
|
||||
|
||||
// inc on bool sets to true
|
||||
static_assert(++ref(false), ""); // expected-warning {{deprecated}}
|
||||
static_assert(++ref(true), ""); // expected-warning {{deprecated}}
|
||||
static_assert(++ref(false), "");
|
||||
// cxx14-warning@-1 {{incrementing expression of type bool}}
|
||||
// cxx20_2b-error@-2 {{incrementing expression of type bool}}
|
||||
static_assert(++ref(true), "");
|
||||
// cxx14-warning@-1 {{incrementing expression of type bool}}
|
||||
// cxx20_2b-error@-2 {{incrementing expression of type bool}}
|
||||
|
||||
int arr[10];
|
||||
static_assert(++ref(&arr[0]) == &arr[1], "");
|
||||
|
@ -323,6 +331,7 @@ namespace incdec {
|
|||
}
|
||||
constexpr int wrong_member = f({0}); // expected-error {{constant}} expected-note {{in call to 'f({.a = 0})'}}
|
||||
constexpr int vol = --ref<volatile int>(0); // expected-error {{constant}} expected-note {{decrement of volatile-qualified}}
|
||||
// cxx20_2b-warning@-1 {{decrement of object of volatile-qualified type 'volatile int' is deprecated}}
|
||||
|
||||
constexpr int incr(int k) {
|
||||
int x = k;
|
||||
|
@ -849,7 +858,7 @@ namespace VirtualFromBase {
|
|||
// Virtual f(), not OK.
|
||||
constexpr X<X<S2>> xxs2;
|
||||
constexpr X<S2> *q = const_cast<X<X<S2>>*>(&xxs2);
|
||||
static_assert(q->f() == sizeof(X<S2>), ""); // expected-error {{constant expression}} expected-note {{virtual function}}
|
||||
static_assert(q->f() == sizeof(X<S2>), ""); // cxx14-error {{constant expression}} cxx14-note {{virtual function}}
|
||||
}
|
||||
|
||||
namespace Lifetime {
|
||||
|
@ -1091,12 +1100,12 @@ namespace IndirectFields {
|
|||
struct A {
|
||||
struct {
|
||||
union {
|
||||
int x = x = 3; // expected-note {{outside its lifetime}}
|
||||
int x = x = 3; // cxx14-note {{outside its lifetime}}
|
||||
};
|
||||
};
|
||||
constexpr A() {}
|
||||
};
|
||||
static_assert(A().x == 3, ""); // expected-error{{not an integral constant expression}} expected-note{{in call to 'A()'}}
|
||||
static_assert(A().x == 3, ""); // cxx14-error{{not an integral constant expression}} cxx14-note{{in call to 'A()'}}
|
||||
|
||||
// Reference another indirect field, with different 'this'.
|
||||
struct B {
|
|
@ -1,6 +1,9 @@
|
|||
// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify %s
|
||||
// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++98 %s
|
||||
// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++11 %s
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected -triple %itanium_abi_triple -Wbind-to-temporary-copy %s
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -triple %itanium_abi_triple -Wbind-to-temporary-copy %s
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=expected,cxx98_14 -triple %itanium_abi_triple -Wbind-to-temporary-copy %s
|
||||
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx98_14 -triple %itanium_abi_triple -Wbind-to-temporary-copy %s
|
||||
// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify=expected,cxx98_14 -triple %itanium_abi_triple -Wbind-to-temporary-copy %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98_14 -triple %itanium_abi_triple -Wbind-to-temporary-copy %s
|
||||
|
||||
class X {
|
||||
public:
|
||||
|
@ -123,7 +126,7 @@ void f(Yb& a) {
|
|||
class AutoPtrRef { };
|
||||
|
||||
class AutoPtr {
|
||||
AutoPtr(AutoPtr &); // expected-note{{declared private here}}
|
||||
AutoPtr(AutoPtr &); // cxx98_14-note{{declared private here}}
|
||||
|
||||
public:
|
||||
AutoPtr();
|
||||
|
@ -139,7 +142,7 @@ AutoPtr test_auto_ptr(bool Cond) {
|
|||
|
||||
AutoPtr p;
|
||||
if (Cond)
|
||||
return p; // expected-error{{calling a private constructor}}
|
||||
return p; // cxx98_14-error{{calling a private constructor}}
|
||||
|
||||
return AutoPtr();
|
||||
}
|
||||
|
@ -149,16 +152,16 @@ struct A1 {
|
|||
~A1();
|
||||
|
||||
private:
|
||||
A1(const A1&); // expected-note 2 {{declared private here}}
|
||||
A1(const A1&); // cxx98_14-note 2 {{declared private here}}
|
||||
};
|
||||
|
||||
A1 f() {
|
||||
// FIXME: redundant diagnostics!
|
||||
return "Hello"; // expected-error {{calling a private constructor}}
|
||||
return "Hello"; // cxx98_14-error {{calling a private constructor}}
|
||||
#if __cplusplus <= 199711L
|
||||
// expected-warning@-2 {{an accessible copy constructor}}
|
||||
#else
|
||||
// expected-warning@-4 {{copying parameter of type 'A1' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
|
||||
// cxx98_14-warning@-4 {{copying parameter of type 'A1' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -stdlib=libc++ -std=c++1z -fcoroutines-ts -fsyntax-only
|
||||
// RUN: %clang_cc1 -verify -std=c++17 -fcoroutines-ts -fsyntax-only %s
|
||||
|
||||
namespace std::experimental {
|
||||
template <class Promise = void> struct coroutine_handle {
|
||||
|
@ -45,6 +45,11 @@ struct MoveOnly {
|
|||
~MoveOnly() {};
|
||||
};
|
||||
|
||||
struct NoCopyNoMove {
|
||||
NoCopyNoMove() = default;
|
||||
NoCopyNoMove(const NoCopyNoMove &) = delete; // expected-note 4{{'NoCopyNoMove' has been explicitly marked deleted here}}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct task {
|
||||
struct promise_type {
|
||||
|
@ -52,18 +57,95 @@ struct task {
|
|||
auto final_suspend() noexcept { return suspend_never{}; }
|
||||
auto get_return_object() { return task{}; }
|
||||
static void unhandled_exception() {}
|
||||
void return_value(T&& value) {}
|
||||
void return_value(T &&value) {} // expected-note 4{{passing argument}}
|
||||
};
|
||||
};
|
||||
|
||||
task<MoveOnly> f() {
|
||||
MoveOnly value;
|
||||
task<NoCopyNoMove> local2val() {
|
||||
NoCopyNoMove value;
|
||||
co_return value; // expected-error {{call to deleted constructor of 'NoCopyNoMove'}}
|
||||
// expected-error@-1 {{value reference to type 'NoCopyNoMove' cannot bind to lvalue of type 'NoCopyNoMove'}}
|
||||
}
|
||||
|
||||
task<NoCopyNoMove &> local2ref() {
|
||||
NoCopyNoMove value;
|
||||
co_return value; // expected-error {{call to deleted constructor of 'NoCopyNoMove'}}
|
||||
}
|
||||
|
||||
// We need the move constructor for construction of the coroutine.
|
||||
task<MoveOnly> param2val(MoveOnly value) {
|
||||
co_return value;
|
||||
}
|
||||
|
||||
int main() {
|
||||
f();
|
||||
return 0;
|
||||
task<NoCopyNoMove> lvalue2val(NoCopyNoMove &value) {
|
||||
co_return value; // expected-error {{rvalue reference to type 'NoCopyNoMove' cannot bind to lvalue of type 'NoCopyNoMove'}}
|
||||
}
|
||||
|
||||
// expected-no-diagnostics
|
||||
task<NoCopyNoMove> rvalue2val(NoCopyNoMove &&value) {
|
||||
co_return value; // expected-error {{rvalue reference to type 'NoCopyNoMove' cannot bind to lvalue of type 'NoCopyNoMove'}}
|
||||
// expected-error@-1 {{call to deleted constructor of 'NoCopyNoMove'}}
|
||||
}
|
||||
|
||||
task<NoCopyNoMove &> lvalue2ref(NoCopyNoMove &value) {
|
||||
co_return value;
|
||||
}
|
||||
|
||||
task<NoCopyNoMove &> rvalue2ref(NoCopyNoMove &&value) {
|
||||
co_return value; // expected-error {{call to deleted constructor of 'NoCopyNoMove'}}
|
||||
}
|
||||
|
||||
struct To {
|
||||
operator MoveOnly() &&;
|
||||
};
|
||||
task<MoveOnly> conversion_operator() {
|
||||
To t;
|
||||
co_return t;
|
||||
}
|
||||
|
||||
struct Construct {
|
||||
Construct(MoveOnly);
|
||||
};
|
||||
task<Construct> converting_constructor() {
|
||||
MoveOnly w;
|
||||
co_return w;
|
||||
}
|
||||
|
||||
struct Derived : MoveOnly {};
|
||||
task<MoveOnly> derived2base() {
|
||||
Derived result;
|
||||
co_return result;
|
||||
}
|
||||
|
||||
struct RetThis {
|
||||
task<RetThis> foo() && {
|
||||
co_return *this; // expected-error {{rvalue reference to type 'RetThis' cannot bind to lvalue of type 'RetThis'}}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename, typename>
|
||||
struct is_same { static constexpr bool value = false; };
|
||||
|
||||
template <typename T>
|
||||
struct is_same<T, T> { static constexpr bool value = true; };
|
||||
|
||||
template <typename T>
|
||||
struct generic_task {
|
||||
struct promise_type {
|
||||
auto initial_suspend() { return suspend_never{}; }
|
||||
auto final_suspend() noexcept { return suspend_never{}; }
|
||||
auto get_return_object() { return generic_task{}; }
|
||||
static void unhandled_exception();
|
||||
template <typename U>
|
||||
void return_value(U &&value) {
|
||||
static_assert(is_same<T, U>::value);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
generic_task<MoveOnly> param2template(MoveOnly value) {
|
||||
co_return value; // We should deduce U = MoveOnly.
|
||||
}
|
||||
|
||||
generic_task<NoCopyNoMove &> lvalue2template(NoCopyNoMove &value) {
|
||||
co_return value; // We should deduce U = NoCopyNoMove&.
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// This file contains references to sections of the Coroutines TS, which can be
|
||||
// found at http://wg21.link/coroutines.
|
||||
|
||||
// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions -fexceptions -Wunused-result
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx20_2b %s -fcxx-exceptions -fexceptions -Wunused-result
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx20_2b %s -fcxx-exceptions -fexceptions -Wunused-result
|
||||
// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -fsyntax-only -verify=expected %s -fcxx-exceptions -fexceptions -Wunused-result
|
||||
|
||||
void no_coroutine_traits_bad_arg_await() {
|
||||
co_await a; // expected-error {{include <experimental/coroutine>}}
|
||||
|
@ -1012,6 +1014,7 @@ struct await_suspend_type_test {
|
|||
// expected-error@+2 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'bool &')}}
|
||||
// expected-error@+1 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'bool &&')}}
|
||||
SuspendTy await_suspend(std::experimental::coroutine_handle<>);
|
||||
// cxx20_2b-warning@-1 {{volatile-qualified return type 'const volatile bool' is deprecated}}
|
||||
void await_resume();
|
||||
};
|
||||
void test_bad_suspend() {
|
||||
|
@ -1033,7 +1036,7 @@ void test_bad_suspend() {
|
|||
await_suspend_type_test<bool &&> a;
|
||||
await_suspend_type_test<bool &> b;
|
||||
await_suspend_type_test<const void> c;
|
||||
await_suspend_type_test<const volatile bool> d;
|
||||
await_suspend_type_test<const volatile bool> d; // cxx20_2b-note {{in instantiation of template class}}
|
||||
co_await a; // expected-note {{call to 'await_suspend' implicitly required by coroutine function here}}
|
||||
co_await b; // expected-note {{call to 'await_suspend' implicitly required by coroutine function here}}
|
||||
co_await c; // OK
|
||||
|
@ -1121,6 +1124,7 @@ struct TestType {
|
|||
}
|
||||
|
||||
CoroMemberTag test_qual(int *, const float &&, volatile void *volatile) const {
|
||||
// cxx20_2b-warning@-1 {{volatile-qualified parameter type}}
|
||||
auto TC = co_yield 0;
|
||||
static_assert(TC.MatchesArgs<const TestType &, int *, const float &&, volatile void *volatile>, "");
|
||||
}
|
||||
|
@ -1219,6 +1223,7 @@ struct DepTestType {
|
|||
}
|
||||
|
||||
CoroMemberTag test_qual(int *, const float &&, volatile void *volatile) const {
|
||||
// cxx20_2b-warning@-1 {{volatile-qualified parameter type}}
|
||||
auto TC = co_yield 0;
|
||||
static_assert(TC.template MatchesArgs<const DepTestType &, int *, const float &&, volatile void *volatile>, "");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
// RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s
|
||||
// RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx20_2b %s
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx20_2b %s -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING
|
||||
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx20_2b %s
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx20_2b %s -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING
|
||||
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=expected,cxx14 %s
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=expected,cxx14 %s -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING
|
||||
|
||||
auto f(); // expected-note {{previous}}
|
||||
int f(); // expected-error {{differ only in their return type}}
|
||||
|
@ -287,7 +293,8 @@ namespace Constexpr {
|
|||
Y<void>().f();
|
||||
constexpr int q = Y<int>().f(); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to '&Y<int>()->f()'}}
|
||||
}
|
||||
struct NonLiteral { ~NonLiteral(); } nl; // expected-note {{user-provided destructor}}
|
||||
struct NonLiteral { ~NonLiteral(); } nl; // cxx14-note {{user-provided destructor}}
|
||||
// cxx20_2b-note@-1 {{'NonLiteral' is not literal because its destructor is not constexpr}}
|
||||
constexpr auto f2(int n) { return nl; } // expected-error {{return type 'Constexpr::NonLiteral' is not a literal type}}
|
||||
}
|
||||
|
||||
|
@ -624,7 +631,7 @@ namespace PR33222 {
|
|||
namespace PR46637 {
|
||||
using A = auto () -> auto; // expected-error {{'auto' not allowed in type alias}}
|
||||
using B = auto (*)() -> auto; // expected-error {{'auto' not allowed in type alias}}
|
||||
template<auto (*)() -> auto> struct X {}; // expected-error {{'auto' not allowed in template parameter until C++17}}
|
||||
template<auto (*)() -> auto> struct X {}; // cxx14-error {{'auto' not allowed in template parameter until C++17}}
|
||||
template<typename T> struct Y { T x; };
|
||||
Y<auto() -> auto> y; // expected-error {{'auto' not allowed in template argument}}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected %s
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected %s
|
||||
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx11 %s
|
||||
|
||||
int* ret_local() {
|
||||
int x = 1;
|
||||
|
@ -179,12 +181,12 @@ void ret_from_lambda() {
|
|||
};
|
||||
(void) [] {
|
||||
int a;
|
||||
// expected-warning@+1 {{C++14}}
|
||||
// cxx11-warning@+1 {{C++14}}
|
||||
return [&b = a] {}; // expected-warning {{address of stack memory associated with local variable 'a' returned}} expected-note {{captured by reference via initialization of lambda capture 'b'}}
|
||||
};
|
||||
(void) [] {
|
||||
int a;
|
||||
// expected-warning@+1 {{C++14}}
|
||||
// cxx11-warning@+1 {{C++14}}
|
||||
return [b = &a] {}; // expected-warning {{address of stack memory associated with local variable 'a' returned}} expected-note {{captured via initialization of lambda capture 'b'}}
|
||||
};
|
||||
}
|
||||
|
@ -197,7 +199,7 @@ HoldsPointer ret_via_member_1() {
|
|||
}
|
||||
HoldsPointer ret_via_member_2() {
|
||||
int n;
|
||||
return HoldsPointer(HoldsPointer{&n}); // expected-warning {{address of stack memory associated with local variable 'n' returned}}
|
||||
return HoldsPointer(HoldsPointer{&n}); // cxx11-warning {{address of stack memory associated with local variable 'n' returned}}
|
||||
}
|
||||
// FIXME: We could diagnose this too.
|
||||
HoldsPointer ret_via_member_3() {
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++20 -verify=cxx20 %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -verify=expected %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -verify=expected %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -verify=expected %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++17 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
|
||||
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
|
||||
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
|
||||
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
|
||||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
|
||||
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
|
||||
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
|
||||
|
||||
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
|
||||
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
|
||||
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
|
||||
|
||||
// definitions for std::move
|
||||
namespace std {
|
||||
|
@ -76,8 +78,8 @@ Derived test1() {
|
|||
Base test2() {
|
||||
Derived d2;
|
||||
return d2; // e1
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
|
||||
}
|
||||
ConstructFromDerived test3() {
|
||||
|
@ -87,22 +89,22 @@ ConstructFromDerived test3() {
|
|||
ConstructFromBase test4() {
|
||||
Derived d4;
|
||||
return d4; // e3
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
|
||||
}
|
||||
ConvertFromDerived test5() {
|
||||
Derived d5;
|
||||
return d5; // e4
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
|
||||
}
|
||||
ConvertFromBase test6() {
|
||||
Derived d6;
|
||||
return d6; // e5
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d6)"
|
||||
}
|
||||
|
||||
|
@ -150,8 +152,8 @@ ConvertFromTrivialBase ok_trivial6(TrivialDerived d) { return d; }
|
|||
Derived testParam1(Derived d) { return d; }
|
||||
Base testParam2(Derived d) {
|
||||
return d; // e6
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
|
||||
}
|
||||
ConstructFromDerived testParam3(Derived d) {
|
||||
|
@ -159,58 +161,58 @@ ConstructFromDerived testParam3(Derived d) {
|
|||
}
|
||||
ConstructFromBase testParam4(Derived d) {
|
||||
return d; // e8
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
|
||||
}
|
||||
ConvertFromDerived testParam5(Derived d) {
|
||||
return d; // e9
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
|
||||
}
|
||||
ConvertFromBase testParam6(Derived d) {
|
||||
return d; // e10
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
|
||||
}
|
||||
|
||||
// If the target is an rvalue reference parameter, do apply the diagnostic.
|
||||
Derived testRParam1(Derived&& d) {
|
||||
return d; // e11
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
|
||||
}
|
||||
Base testRParam2(Derived&& d) {
|
||||
return d; // e12
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
|
||||
}
|
||||
ConstructFromDerived testRParam3(Derived&& d) {
|
||||
return d; // e13
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
|
||||
}
|
||||
ConstructFromBase testRParam4(Derived&& d) {
|
||||
return d; // e14
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
|
||||
}
|
||||
ConvertFromDerived testRParam5(Derived&& d) {
|
||||
return d; // e15
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
|
||||
}
|
||||
ConvertFromBase testRParam6(Derived&& d) {
|
||||
return d; // e16
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
|
||||
}
|
||||
|
||||
|
@ -226,8 +228,8 @@ decltype(auto) testRetRef4(Derived&& d) { return (d); }
|
|||
Base testParens1() {
|
||||
Derived d;
|
||||
return (d); // e17
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:15}:"std::move(d)"
|
||||
}
|
||||
ConstructFromDerived testParens2() {
|
||||
|
@ -239,43 +241,43 @@ ConstructFromDerived testParens2() {
|
|||
void throw_derived();
|
||||
Derived testEParam1() {
|
||||
try { throw_derived(); } catch (Derived d) { return d; } // e19
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:57-[[@LINE-3]]:58}:"std::move(d)"
|
||||
__builtin_unreachable();
|
||||
}
|
||||
Base testEParam2() {
|
||||
try { throw_derived(); } catch (Derived d) { return d; } // e20
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:57-[[@LINE-3]]:58}:"std::move(d)"
|
||||
__builtin_unreachable();
|
||||
}
|
||||
ConstructFromDerived testEParam3() {
|
||||
try { throw_derived(); } catch (Derived d) { return d; } // e21
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:57-[[@LINE-3]]:58}:"std::move(d)"
|
||||
__builtin_unreachable();
|
||||
}
|
||||
ConstructFromBase testEParam4() {
|
||||
try { throw_derived(); } catch (Derived d) { return d; } // e22
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:57-[[@LINE-3]]:58}:"std::move(d)"
|
||||
__builtin_unreachable();
|
||||
}
|
||||
ConvertFromDerived testEParam5() {
|
||||
try { throw_derived(); } catch (Derived d) { return d; } // e23
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:57-[[@LINE-3]]:58}:"std::move(d)"
|
||||
__builtin_unreachable();
|
||||
}
|
||||
ConvertFromBase testEParam6() {
|
||||
try { throw_derived(); } catch (Derived d) { return d; } // e24
|
||||
// expected-warning@-1{{will be copied despite being returned by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being returned by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:57-[[@LINE-3]]:58}:"std::move(d)"
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
@ -316,8 +318,8 @@ OnlyCopyable ok_copyparam2(OnlyCopyable c) { return c; }
|
|||
|
||||
void test_throw1(Derived&& d) {
|
||||
throw d; // e25
|
||||
// expected-warning@-1{{will be copied despite being thrown by name}}
|
||||
// expected-note@-2{{to avoid copying}}
|
||||
// cxx11_17-warning@-1{{will be copied despite being thrown by name}}
|
||||
// cxx11_17-note@-2{{to avoid copying}}
|
||||
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:12}:"std::move(d)"
|
||||
}
|
||||
|
||||
|
@ -336,7 +338,7 @@ void ok_throw8(OnlyCopyable d) { throw d; }
|
|||
namespace test_delete {
|
||||
struct Base {
|
||||
Base();
|
||||
Base(Base &&) = delete; // cxx20-note {{'Base' has been explicitly marked deleted here}}
|
||||
Base(Base &&) = delete; // cxx20_2b-note {{'Base' has been explicitly marked deleted here}}
|
||||
Base(Base const &);
|
||||
};
|
||||
|
||||
|
@ -344,6 +346,6 @@ struct Derived : public Base {};
|
|||
|
||||
Base test_ok() {
|
||||
Derived d;
|
||||
return d; // cxx20-error {{call to deleted constructor of 'test_delete::Base'}}
|
||||
return d; // cxx20_2b-error {{call to deleted constructor of 'test_delete::Base'}}
|
||||
}
|
||||
} // namespace test_delete
|
||||
|
|
Loading…
Reference in New Issue