Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -1969,7 +1969,7 @@ "use __attribute__((visibility(\"hidden\"))) attribute instead">; // C++ Concepts TS -def err_concept_decl_non_template : Error< +def err_concept_wrong_decl_kind : Error< "'concept' can only appear on the definition of a function template or variable template">; def err_concept_decls_may_only_appear_in_namespace_scope : Error< "concept declarations may only appear in namespace scope">; Index: cfe/trunk/lib/Sema/SemaDecl.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp +++ cfe/trunk/lib/Sema/SemaDecl.cpp @@ -3662,6 +3662,14 @@ return TagD; } + if (DS.isConceptSpecified()) { + // C++ Concepts TS [dcl.spec.concept]p1: A concept definition refers to + // either a function concept and its definition or a variable concept and + // its initializer. + Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind); + return TagD; + } + DiagnoseFunctionSpecifiers(DS); if (DS.isFriendSpecified()) { @@ -4865,7 +4873,7 @@ // template, declared in namespace scope if (!TemplateParamLists.size()) { Diag(D.getDeclSpec().getConceptSpecLoc(), - diag::err_concept_decl_non_template); + diag:: err_concept_wrong_decl_kind); return nullptr; } Index: cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp =================================================================== --- cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp +++ cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp @@ -23,3 +23,13 @@ template concept bool D6; // expected-error {{variable concept declaration must be initialized}} +// 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 concept class TCC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} +template concept struct TCS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} +template concept union TCU1 {}; // 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}}