From: Nathan Wilson Date: Wed, 4 Nov 2015 18:18:35 +0000 (+0000) Subject: [Concepts] Add diagnostics which fall under [dcl.spec.concept]p1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f541a4da9ff2b344f02f6634a7276bd2d00a6c5;p=clang [Concepts] Add diagnostics which fall under [dcl.spec.concept]p1 Summary: Diagnose when the 'concept' specifier is used on a typedef or function parameter. Reviewers: rsmith, hubert.reinterpretcast, aaron.ballman, faisalv Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14316 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252061 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index e188094f90..b14109a6d7 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5119,6 +5119,9 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, if (D.getDeclSpec().isConstexprSpecified()) Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr) << 1; + if (D.getDeclSpec().isConceptSpecified()) + Diag(D.getDeclSpec().getConceptSpecLoc(), + diag::err_concept_wrong_decl_kind); if (D.getName().Kind != UnqualifiedId::IK_Identifier) { Diag(D.getName().StartLocation, diag::err_typedef_not_identifier) @@ -10277,6 +10280,8 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { if (DS.isConstexprSpecified()) Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr) << 0; + if (DS.isConceptSpecified()) + Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind); DiagnoseFunctionSpecifiers(DS); 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 index e51a441795..ded6ed013c 100644 --- 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 @@ -37,5 +37,7 @@ concept enum CE1 {}; // expected-error {{'concept' can only appear on the defini 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}} +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}}