]> granicus.if.org Git - clang/commitdiff
[Concepts] Add diagnostics which fall under [dcl.spec.concept]p1
authorNathan Wilson <nwilson20@gmail.com>
Wed, 4 Nov 2015 18:18:35 +0000 (18:18 +0000)
committerNathan Wilson <nwilson20@gmail.com>
Wed, 4 Nov 2015 18:18:35 +0000 (18:18 +0000)
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

lib/Sema/SemaDecl.cpp
test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

index e188094f90abf720cd1da0efce27f1a7a7454e88..b14109a6d79e727f1a70bb78a1e4014e77fcdf64 100644 (file)
@@ -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);
 
index e51a441795c3e3965f56f71582cfe3e1fb05ad5e..ded6ed013c0534e05219e0acfda932687532f1ae 100644 (file)
@@ -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}}