diff options
Diffstat (limited to 'test/CXX/concepts-ts')
8 files changed, 237 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 0000000000..863b608b5b --- /dev/null +++ b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp @@ -0,0 +1,61 @@ +// 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}} + +template <typename T> concept bool VCEI{ true }; +template concept bool VCEI<int>; // expected-error {{'concept' cannot be applied on an explicit instantiation}} +extern template concept bool VCEI<int>; // expected-error {{'concept' cannot be applied on an explicit instantiation}} + +template <typename T> concept bool VCPS{ true }; +template <typename T> concept bool VCPS<T *>{ true }; // expected-error {{'concept' cannot be applied on an partial specialization}} + +template <typename T> concept bool VCES{ true }; +template <> concept bool VCES<int>{ true }; // expected-error {{'concept' cannot be applied on an explicit specialization}} + +template <typename T> concept bool FCEI() { return true; } +template concept bool FCEI<int>(); // expected-error {{'concept' cannot be applied on an explicit instantiation}} +extern template concept bool FCEI<int>(); // expected-error {{'concept' cannot be applied on an explicit instantiation}} + +template <typename T> concept bool FCES() { return true; } +template <> concept bool FCES<bool>() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}} 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 0000000000..477910986d --- /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 0000000000..69672ca830 --- /dev/null +++ b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp @@ -0,0 +1,25 @@ +// 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}} + +template<typename T> +concept const bool fcrtc() { return true; } // expected-error {{declared return type of function concept must be 'bool'}} + +template<typename T> +concept int fcrti() { return 5; } // expected-error {{declared return type of function concept must be 'bool'}} + +template<typename T> +concept float fcrtf() { return 5.5; } // expected-error {{declared return type of function concept must be 'bool'}} + +template<typename T> +concept decltype(auto) fcrtd(void) { return true; } // expected-error {{declared return type of function concept must be 'bool'}} diff --git a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp new file mode 100644 index 0000000000..f8a1bb72e3 --- /dev/null +++ b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s + +template<typename T> +concept bool vc { true }; + +template<typename T> +struct B { typedef bool Boolean; }; + +template<int N> +B<void>::Boolean concept vctb(!0); + +template<typename T> +concept const bool vctc { true }; // expected-error {{declared type of variable concept must be 'bool'}} + +template<typename T> +concept int vcti { 5 }; // expected-error {{declared type of variable concept must be 'bool'}} + +template<typename T> +concept float vctf { 5.5 }; // expected-error {{declared type of variable concept must be 'bool'}} + +template<typename T> +concept auto vcta { true }; // expected-error {{declared type of variable concept must be 'bool'}} + +template<typename T> +concept decltype(auto) vctd { true }; // expected-error {{declared type of variable concept must be 'bool'}} diff --git a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp new file mode 100644 index 0000000000..1bad6bb932 --- /dev/null +++ b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s + +template <typename T> concept bool FCEI() { return true; } // expected-note {{previous declaration is here}} expected-note {{previous declaration is here}} +template bool FCEI<int>(); // expected-error {{function concept cannot be explicitly instantiated}} +extern template bool FCEI<double>(); // expected-error {{function concept cannot be explicitly instantiated}} + +template <typename T> concept bool FCES() { return true; } // expected-note {{previous declaration is here}} +template <> bool FCES<int>() { return true; } // expected-error {{function concept cannot be explicitly specialized}} + +template <typename T> concept bool VC { true }; // expected-note {{previous declaration is here}} expected-note {{previous declaration is here}} +template bool VC<int>; // expected-error {{variable concept cannot be explicitly instantiated}} +extern template bool VC<double>; // expected-error {{variable concept cannot be explicitly instantiated}} + +template <typename T> concept bool VCES { true }; // expected-note {{previous declaration is here}} +template <> bool VCES<int> { true }; // expected-error {{variable concept cannot be explicitly specialized}} + +template <typename T> concept bool VCPS { true }; // expected-note {{previous declaration is here}} +template <typename T> bool VCPS<T *> { true }; // expected-error {{variable concept cannot be partially specialized}} diff --git a/test/CXX/concepts-ts/dcl.dcl/lit.cfg.py b/test/CXX/concepts-ts/dcl.dcl/lit.cfg.py new file mode 100644 index 0000000000..c705e3cb93 --- /dev/null +++ b/test/CXX/concepts-ts/dcl.dcl/lit.cfg.py @@ -0,0 +1,26 @@ +# -*- Python -*- + +import os +import lit.formats + +from lit.llvm import llvm_config + +# Configuration file for the 'lit' test runner. + +# name: The name of this test suite. +config.name = 'Clang-Concepts-TS-Unsupported' + +# testFormat: The test format to use to interpret tests. +# +# For now we require '&&' between commands, until they get globally killed and +# the test runner updated. +config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu', + '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs'] + +config.unsupported = True + +# test_source_root: The root path where tests are located. +config.test_source_root = os.path.dirname(__file__) diff --git a/test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp b/test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp new file mode 100644 index 0000000000..16da146a96 --- /dev/null +++ b/test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -verify %s + +template<typename T> concept C = true; +static_assert(C<int>); // expected-error{{sorry, unimplemented concepts feature concept specialization used}} diff --git a/test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp b/test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp new file mode 100644 index 0000000000..d1ad0404ef --- /dev/null +++ b/test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp @@ -0,0 +1,65 @@ +// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s + +namespace nodiag { + +template <typename T> requires bool(T()) +struct A; +template <typename U> requires bool(U()) +struct A; + +} // end namespace nodiag + +namespace diag { + +template <typename T> requires true // expected-note{{previous template declaration is here}} +struct A; +template <typename T> struct A; // expected-error{{associated constraints differ in template redeclaration}} + +template <typename T> struct B; // expected-note{{previous template declaration is here}} +template <typename T> requires true // expected-error{{associated constraints differ in template redeclaration}} +struct B; + +template <typename T> requires true // expected-note{{previous template declaration is here}} +struct C; +template <typename T> requires !0 // expected-error{{associated constraints differ in template redeclaration}} +struct C; + +} // end namespace diag + +namespace nodiag { + +struct AA { + template <typename T> requires someFunc(T()) + struct A; +}; + +template <typename T> requires someFunc(T()) +struct AA::A { }; + +struct AAF { + template <typename T> requires someFunc(T()) + friend struct AA::A; +}; + +} // end namespace nodiag + +namespace diag { + +template <unsigned N> +struct TA { + template <template <unsigned> class TT> requires TT<N>::happy // expected-note 2{{previous template declaration is here}} + struct A; + + struct AF; +}; + +template <unsigned N> +template <template <unsigned> class TT> struct TA<N>::A { }; // expected-error{{associated constraints differ in template redeclaration}} + +template <unsigned N> +struct TA<N>::AF { + template <template <unsigned> class TT> requires TT<N + 0>::happy // expected-error{{associated constraints differ in template redeclaration}} + friend struct TA::A; +}; + +} // end namespace diag |