[PATCH] D28258: [Sema] Handle invalid noexcept expressions correctly.
don hinton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 3 15:00:54 PST 2017
hintonda created this revision.
hintonda added reviewers: sepavloff, rsmith, aaron.ballman.
hintonda added a subscriber: cfe-commits.
Treat invalid noexcept specifications in the same way we
treat invalid throw specifications, by not resetting the exception
type to EST_None, and testing isUsable instead of isInvalid.
Rational: In order to add source locations for exception
specifications (see https://reviews.llvm.org/D20428) we need to
maintain the correct exception type, otherwise, FunctionDecl types
won't include space for source ranges, but the associated
TypeSourceInfo type will, causing ASTContext::adjustExceptionSpec to
assert once source ranges have been added.
https://reviews.llvm.org/D28258
Files:
lib/Parse/ParseDeclCXX.cpp
lib/Sema/TreeTransform.h
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5041,20 +5041,20 @@
EnterExpressionEvaluationContext Unevaluated(getSema(),
Sema::ConstantEvaluated);
ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
- if (NoexceptExpr.isInvalid())
+ if (!NoexceptExpr.isUsable())
return true;
// FIXME: This is bogus, a noexcept expression is not a condition.
NoexceptExpr = getSema().CheckBooleanCondition(Loc, NoexceptExpr.get());
- if (NoexceptExpr.isInvalid())
+ if (!NoexceptExpr.isUsable())
return true;
if (!NoexceptExpr.get()->isValueDependent()) {
NoexceptExpr = getSema().VerifyIntegerConstantExpression(
NoexceptExpr.get(), nullptr,
diag::err_noexcept_needs_constant_expression,
/*AllowFold*/false);
- if (NoexceptExpr.isInvalid())
+ if (!NoexceptExpr.isUsable())
return true;
}
Index: lib/Parse/ParseDeclCXX.cpp
===================================================================
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -3544,8 +3544,6 @@
NoexceptExpr =
Actions.CheckBooleanCondition(KeywordLoc, NoexceptExpr.get());
NoexceptRange = SourceRange(KeywordLoc, T.getCloseLocation());
- } else {
- NoexceptType = EST_None;
}
} else {
// There is no argument.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28258.82959.patch
Type: text/x-patch
Size: 1528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170103/bb478e6b/attachment.bin>
More information about the cfe-commits
mailing list