aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-06 06:49:02 +0000
committerChris Lattner <sabre@nondot.org>2008-10-06 06:49:02 +0000
commit45b6b9d080ac56917337d73d8f1cd6374b27b05d (patch)
tree864fcba0f3de84e80f75f96e295b220bb0366346 /lib/Sema/SemaDecl.cpp
parenta4d55d89c8076b402bb168e3edeef0c2cd2a78c3 (diff)
Add a Expr::isEvaluatable method, eliminate isBuiltinConstantExpr
which is checking for something that can be inconsistent with what we can constant fold. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57159 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 74ce855add..125d91cdba 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -879,14 +879,6 @@ bool Sema::CheckAddressConstantExpression(const Expr* Init) {
case Expr::StringLiteralClass:
case Expr::ObjCStringLiteralClass:
return false;
- case Expr::CallExprClass: {
- const CallExpr *CE = cast<CallExpr>(Init);
- if (CE->isBuiltinConstantExpr(Context))
- return false;
- Diag(Init->getExprLoc(),
- diag::err_init_element_not_constant, Init->getSourceRange());
- return true;
- }
case Expr::UnaryOperatorClass: {
const UnaryOperator *Exp = cast<UnaryOperator>(Init);
@@ -1080,8 +1072,11 @@ bool Sema::CheckArithmeticConstantExpression(const Expr* Init) {
return false;
case Expr::CallExprClass: {
const CallExpr *CE = cast<CallExpr>(Init);
- if (CE->isBuiltinConstantExpr(Context))
+
+ // Allow any constant foldable calls to builtins.
+ if (CE->isBuiltinCall() && CE->isEvaluatable(Context))
return false;
+
Diag(Init->getExprLoc(),
diag::err_init_element_not_constant, Init->getSourceRange());
return true;
@@ -1226,7 +1221,7 @@ bool Sema::CheckArithmeticConstantExpression(const Expr* Init) {
// Okay, the evaluated side evaluates to a constant, so we accept this.
// Check to see if the other side is obviously not a constant. If so,
// emit a warning that this is a GNU extension.
- if (FalseSide && !FalseSide->tryEvaluate(Val, Context))
+ if (FalseSide && !FalseSide->isEvaluatable(Context))
Diag(Init->getExprLoc(),
diag::ext_typecheck_expression_not_constant_but_accepted,
FalseSide->getSourceRange());