[cfe-commits] r70089 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/PR2963-enum-constant.c
Eli Friedman
eli.friedman at gmail.com
Sat Apr 25 15:26:58 PDT 2009
Author: efriedma
Date: Sat Apr 25 17:26:58 2009
New Revision: 70089
URL: http://llvm.org/viewvc/llvm-project?rev=70089&view=rev
Log:
Make VerifyIntegerConstantExpr print extension warnings for non-ICEs.
Overall, I'm not particularly happy with the current situation regarding
constant expression diagnostics, but I plan to improve it at some point.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/PR2963-enum-constant.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=70089&r1=70088&r2=70089&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Apr 25 17:26:58 2009
@@ -4929,6 +4929,13 @@
}
bool Sema::VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result){
+ llvm::APSInt ICEResult;
+ if (E->isIntegerConstantExpr(ICEResult, Context)) {
+ if (Result)
+ *Result = ICEResult;
+ return false;
+ }
+
Expr::EvalResult EvalResult;
if (!E->Evaluate(EvalResult, Context) || !EvalResult.Val.isInt() ||
@@ -4946,14 +4953,12 @@
return true;
}
- if (EvalResult.Diag) {
- Diag(E->getExprLoc(), diag::ext_expr_not_ice) <<
- E->getSourceRange();
-
- // Print the reason it's not a constant.
- if (Diags.getDiagnosticLevel(diag::ext_expr_not_ice) != Diagnostic::Ignored)
- Diag(EvalResult.DiagLoc, EvalResult.Diag);
- }
+ Diag(E->getExprLoc(), diag::ext_expr_not_ice) <<
+ E->getSourceRange();
+
+ if (EvalResult.Diag &&
+ Diags.getDiagnosticLevel(diag::ext_expr_not_ice) != Diagnostic::Ignored)
+ Diag(EvalResult.DiagLoc, EvalResult.Diag);
if (Result)
*Result = EvalResult.Val.getInt();
Modified: cfe/trunk/test/Sema/PR2963-enum-constant.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/PR2963-enum-constant.c?rev=70089&r1=70088&r2=70089&view=diff
==============================================================================
--- cfe/trunk/test/Sema/PR2963-enum-constant.c (original)
+++ cfe/trunk/test/Sema/PR2963-enum-constant.c Sat Apr 25 17:26:58 2009
@@ -13,5 +13,5 @@
enum
{
- SOME_VALUE= FLOAT_TO_SHORT_FIXED(0.1)
+ SOME_VALUE= FLOAT_TO_SHORT_FIXED(0.1) // expected-warning{{expression is not integer constant expression}}
};
More information about the cfe-commits
mailing list