aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-10-09 18:31:23 +0000
committerDouglas Gregor <dgregor@apple.com>2011-10-09 18:31:23 +0000
commit5c340e803ed2e384ff47f3e560df253515c92e1e (patch)
tree2ab9b4c4c4a3b165a766f6282d8631466507c9f0 /lib/Sema/SemaTemplateInstantiateDecl.cpp
parent85035647bc4e6cc38cc399a7d30f9a8857f345fa (diff)
After instantiating a 'noexcept' expression, be sure to convert it to
a boolean value and check that it is a constant expression. Fixes PR11084. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141511 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 4fea4002cb..c8628dbd49 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2286,7 +2286,21 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New,
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
ExprResult E = SemaRef.SubstExpr(OldNoexceptExpr, TemplateArgs);
if (E.isUsable())
+ E = SemaRef.CheckBooleanCondition(E.get(), E.get()->getLocStart());
+
+ if (E.isUsable()) {
+ SourceLocation ErrLoc;
+ llvm::APSInt NoexceptVal;
NoexceptExpr = E.take();
+ if (!NoexceptExpr->isTypeDependent() &&
+ !NoexceptExpr->isValueDependent() &&
+ !NoexceptExpr->isIntegerConstantExpr(NoexceptVal, SemaRef.Context,
+ &ErrLoc, /*evaluated=*/false)){
+ SemaRef.Diag(ErrLoc, diag::err_noexcept_needs_constant_expression)
+ << NoexceptExpr->getSourceRange();
+ NoexceptExpr = 0;
+ }
+ }
}
// Rebuild the function type