summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorNathan Wilson <nwilson20@gmail.com>2016-01-29 04:43:59 +0000
committerNathan Wilson <nwilson20@gmail.com>2016-01-29 04:43:59 +0000
commit4661c610be1e5074359a0afdf77d76a76882141f (patch)
treea89e92d18e825ab3a375ef61a11a5dbcbe572a6f /clang/lib/Sema/SemaDecl.cpp
parent9398f86a2acb8c256d0601df1cea28cb5bb107b8 (diff)
downloadbcm5719-llvm-4661c610be1e5074359a0afdf77d76a76882141f.tar.gz
bcm5719-llvm-4661c610be1e5074359a0afdf77d76a76882141f.zip
[Concepts] Implement a portion of Concepts TS[dcl.spec.concept]p5 and p6:
Diagnose if the return type of a function concept or declaration type of a variable concept is not bool. Reviewers: hubert.reinterpretcast Differential Revision: http://reviews.llvm.org/D16163 llvm-svn: 259159
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp17
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())
OpenPOWER on IntegriCloud