diff options
Diffstat (limited to 'test/CXX/concepts-ts/dcl.dcl')
3 files changed, 69 insertions, 0 deletions
diff --git a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp new file mode 100644 index 0000000..ded6ed0 --- /dev/null +++ b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -fcxx-exceptions -x c++ -verify %s + +namespace A { + template<typename T> concept bool C1() { return true; } + + template<typename T> concept bool C2 = true; +} + +template<typename T> concept bool C3() { return (throw 0, true); } +static_assert(noexcept(C3<int>()), "function concept should be treated as if noexcept(true) specified"); + +template<typename T> concept bool D1(); // expected-error {{function concept declaration must be a definition}} + +struct B { + template<typename T> concept bool D2() { return true; } // expected-error {{concept declarations may only appear in namespace scope}} +}; + +struct C { + template<typename T> static concept bool D3 = true; // expected-error {{concept declarations may only appear in namespace scope}} +}; + +concept bool D4() { return true; } // expected-error {{'concept' can only appear on the definition of a function template or variable template}} + +concept bool D5 = true; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} + +template<typename T> +concept bool D6; // expected-error {{variable concept declaration must be initialized}} + +template<typename T> +concept bool D7() throw(int) { return true; } // expected-error {{function concept cannot have exception specification}} + +// Tag +concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} +concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} +concept union CU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} +concept enum CE1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} +template <typename T> concept class TCC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} +template <typename T> concept struct TCS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} +template <typename T> concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} +typedef concept int CI; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} +void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}} + +concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} diff --git a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp new file mode 100644 index 0000000..4779109 --- /dev/null +++ b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s + +template<typename T> concept thread_local bool VCTL = true; // expected-error {{variable concept cannot be declared 'thread_local'}} + +template<typename T> concept constexpr bool VCC = true; // expected-error {{variable concept cannot be declared 'constexpr'}} + +template<typename T> concept inline bool FCI() { return true; } // expected-error {{function concept cannot be declared 'inline'}} + +struct X { + template<typename T> concept friend bool FCF() { return true; } // expected-error {{function concept cannot be declared 'friend'}} +}; + +template<typename T> concept constexpr bool FCC() { return true; } // expected-error {{function concept cannot be declared 'constexpr'}} diff --git a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp new file mode 100644 index 0000000..38593bc --- /dev/null +++ b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s + +template<typename T> +concept bool fcpv(void) { return true; } + +template<typename T> +concept bool fcpi(int i = 0) { return true; } // expected-error {{function concept cannot have any parameters}} + +template<typename... Ts> +concept bool fcpp(Ts... ts) { return true; } // expected-error {{function concept cannot have any parameters}} + +template<typename T> +concept bool fcpva(...) { return true; } // expected-error {{function concept cannot have any parameters}} |