1 // RUN: %clang_cc1 -std=c++14 -fconcepts-ts -fcxx-exceptions -x c++ -verify %s 2 3 namespace A { 4 template<typename T> concept bool C1() { return true; } 5 6 template<typename T> concept bool C2 = true; 7 } 8 9 template<typename T> concept bool C3() { return (throw 0, true); } 10 static_assert(noexcept(C3<int>()), "function concept should be treated as if noexcept(true) specified"); 11 12 template<typename T> concept bool D1(); // expected-error {{function concept declaration must be a definition}} 13 14 struct B { 15 template<typename T> concept bool D2() { return true; } // expected-error {{concept declarations may only appear in namespace scope}} 16 }; 17 18 struct C { 19 template<typename T> static concept bool D3 = true; // expected-error {{concept declarations may only appear in namespace scope}} 20 }; 21 22 concept bool D4() { return true; } // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 23 24 concept bool D5 = true; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 25 26 template<typename T> 27 concept bool D6; // expected-error {{variable concept declaration must be initialized}} 28 29 template<typename T> 30 concept bool D7() throw(int) { return true; } // expected-error {{function concept cannot have exception specification}} 31 32 // Tag 33 concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 34 concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 35 concept union CU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 36 concept enum CE1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 37 template <typename T> concept class TCC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 38 template <typename T> concept struct TCS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 39 template <typename T> concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 40 typedef concept int CI; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 41 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 42 43 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} 44 45 template <typename T> concept bool VCEI{ true }; 46 template concept bool VCEI<int>; // expected-error {{'concept' cannot be applied on an explicit instantiation}} 47 extern template concept bool VCEI<int>; // expected-error {{'concept' cannot be applied on an explicit instantiation}} 48 49 template <typename T> concept bool VCPS{ true }; 50 template <typename T> concept bool VCPS<T *>{ true }; // expected-error {{'concept' cannot be applied on an partial specialization}} 51 52 template <typename T> concept bool VCES{ true }; 53 template <> concept bool VCES<int>{ true }; // expected-error {{'concept' cannot be applied on an explicit specialization}} 54 55 template <typename T> concept bool FCEI() { return true; } 56 template concept bool FCEI<int>(); // expected-error {{'concept' cannot be applied on an explicit instantiation}} 57 extern template concept bool FCEI<int>(); // expected-error {{'concept' cannot be applied on an explicit instantiation}} 58 59 template <typename T> concept bool FCES() { return true; } 60 template <> concept bool FCES<bool>() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}} 61