Skip to content

Commit

Permalink
[Concepts] Add diagnostics which fall under [dcl.spec.concept]p1
Browse files Browse the repository at this point in the history
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

llvm-svn: 252061
  • Loading branch information
Wilson-N committed Nov 4, 2015
1 parent e41a8c4 commit f22124f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clang/lib/Sema/SemaDecl.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down
Expand Up @@ -37,5 +37,7 @@ concept enum CE1 {}; // expected-error {{'concept' can only appear on the defini
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}}

0 comments on commit f22124f

Please sign in to comment.