diff options
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index cb79948341f..11d51a09794 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6001,6 +6001,15 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, << 0 << 3; NewVD->setInvalidDecl(true); } + + // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the + // following restrictions: + // - The declared type shall have the type bool. + if (!Context.hasSameType(NewVD->getType(), Context.BoolTy) && + !NewVD->isInvalidDecl()) { + Diag(D.getIdentifierLoc(), diag::err_variable_concept_bool_decl); + NewVD->setInvalidDecl(true); + } } } @@ -7683,6 +7692,14 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // C++ Concepts TS [dcl.spec.concept]p5: A function concept has the // following restrictions: + // - The declared return type shall have the type bool. + if (!Context.hasSameType(FPT->getReturnType(), Context.BoolTy)) { + Diag(D.getIdentifierLoc(), diag::err_function_concept_bool_ret); + NewFD->setInvalidDecl(); + } + + // C++ Concepts TS [dcl.spec.concept]p5: A function concept has the + // following restrictions: // - The declaration's parameter list shall be equivalent to an empty // parameter list. if (FPT->getNumParams() > 0 || FPT->isVariadic()) |