mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 12:26:52 +08:00
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. llvm-svn: 70089
This commit is contained in:
@@ -4929,6 +4929,13 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
|
||||
}
|
||||
|
||||
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 @@ bool Sema::VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result){
|
||||
return true;
|
||||
}
|
||||
|
||||
if (EvalResult.Diag) {
|
||||
Diag(E->getExprLoc(), diag::ext_expr_not_ice) <<
|
||||
E->getSourceRange();
|
||||
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);
|
||||
}
|
||||
if (EvalResult.Diag &&
|
||||
Diags.getDiagnosticLevel(diag::ext_expr_not_ice) != Diagnostic::Ignored)
|
||||
Diag(EvalResult.DiagLoc, EvalResult.Diag);
|
||||
|
||||
if (Result)
|
||||
*Result = EvalResult.Val.getInt();
|
||||
|
||||
@@ -13,5 +13,5 @@ enum
|
||||
|
||||
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}}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user