forked from OSchip/llvm-project
Change the diagnostics that the evaluator reports to be of type NOTE.
llvm-svn: 60301
This commit is contained in:
parent
5862001157
commit
b33d6c8611
|
@ -617,12 +617,18 @@ DIAG(warn_pragma_pack_pop_failed, WARNING,
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// Constant expressions
|
// Constant expressions
|
||||||
DIAG(err_expr_not_constant, ERROR,
|
DIAG(err_expr_not_ice, ERROR,
|
||||||
"expression is invalid in a constant expression")
|
"expression is not an integer constant expression")
|
||||||
DIAG(err_expr_divide_by_zero, ERROR,
|
DIAG(ext_expr_not_ice, EXTENSION,
|
||||||
"division by zero")
|
"expression is not integer constant expression "
|
||||||
DIAG(ext_comma_in_constant_expr, EXTENSION,
|
"(but is allowed as an extension)")
|
||||||
"C does not permit evaluated commas in constant expression")
|
|
||||||
|
DIAG(note_comma_in_ice, NOTE,
|
||||||
|
"C does not permit evaluated commas in an integer constant expression")
|
||||||
|
DIAG(note_invalid_subexpr_in_ice, NOTE,
|
||||||
|
"subexpression not valid in an integer constant expression")
|
||||||
|
DIAG(note_expr_divide_by_zero, NOTE,
|
||||||
|
"division by zero")
|
||||||
|
|
||||||
// Semantic analysis of string and character constant literals.
|
// Semantic analysis of string and character constant literals.
|
||||||
DIAG(ext_nonstandard_escape, EXTENSION,
|
DIAG(ext_nonstandard_escape, EXTENSION,
|
||||||
|
|
|
@ -366,7 +366,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VisitExpr(Expr *E) {
|
bool VisitExpr(Expr *E) {
|
||||||
return Error(E->getLocStart(), diag::err_expr_not_constant, E);
|
return Error(E->getLocStart(), diag::note_invalid_subexpr_in_ice, E);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VisitParenExpr(ParenExpr *E) { return Visit(E->getSubExpr()); }
|
bool VisitParenExpr(ParenExpr *E) { return Visit(E->getSubExpr()); }
|
||||||
|
@ -434,7 +434,7 @@ bool IntExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, random variable references are not constants.
|
// Otherwise, random variable references are not constants.
|
||||||
return Error(E->getLocStart(), diag::err_expr_not_constant, E);
|
return Error(E->getLocStart(), diag::note_invalid_subexpr_in_ice, E);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way
|
/// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way
|
||||||
|
@ -497,7 +497,7 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) {
|
||||||
|
|
||||||
switch (E->isBuiltinCall()) {
|
switch (E->isBuiltinCall()) {
|
||||||
default:
|
default:
|
||||||
return Error(E->getLocStart(), diag::err_expr_not_constant, E);
|
return Error(E->getLocStart(), diag::note_invalid_subexpr_in_ice, E);
|
||||||
case Builtin::BI__builtin_classify_type:
|
case Builtin::BI__builtin_classify_type:
|
||||||
Result.setIsSigned(true);
|
Result.setIsSigned(true);
|
||||||
Result = EvaluateBuiltinClassifyType(E);
|
Result = EvaluateBuiltinClassifyType(E);
|
||||||
|
@ -520,7 +520,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (Info.ShortCircuit)
|
if (Info.ShortCircuit)
|
||||||
return Extension(E->getOperatorLoc(), diag::ext_comma_in_constant_expr,E);
|
return Extension(E->getOperatorLoc(), diag::note_comma_in_ice, E);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -676,7 +676,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
|
||||||
|
|
||||||
switch (E->getOpcode()) {
|
switch (E->getOpcode()) {
|
||||||
default:
|
default:
|
||||||
return Error(E->getOperatorLoc(), diag::err_expr_not_constant, E);
|
return Error(E->getOperatorLoc(), diag::note_invalid_subexpr_in_ice, E);
|
||||||
case BinaryOperator::Mul: Result *= RHS; return true;
|
case BinaryOperator::Mul: Result *= RHS; return true;
|
||||||
case BinaryOperator::Add: Result += RHS; return true;
|
case BinaryOperator::Add: Result += RHS; return true;
|
||||||
case BinaryOperator::Sub: Result -= RHS; return true;
|
case BinaryOperator::Sub: Result -= RHS; return true;
|
||||||
|
@ -685,13 +685,12 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
|
||||||
case BinaryOperator::Or: Result |= RHS; return true;
|
case BinaryOperator::Or: Result |= RHS; return true;
|
||||||
case BinaryOperator::Div:
|
case BinaryOperator::Div:
|
||||||
if (RHS == 0)
|
if (RHS == 0)
|
||||||
return Error(E->getOperatorLoc(), diag::err_expr_divide_by_zero,
|
return Error(E->getOperatorLoc(), diag::note_expr_divide_by_zero, E);
|
||||||
E);
|
|
||||||
Result /= RHS;
|
Result /= RHS;
|
||||||
break;
|
break;
|
||||||
case BinaryOperator::Rem:
|
case BinaryOperator::Rem:
|
||||||
if (RHS == 0)
|
if (RHS == 0)
|
||||||
return Error(E->getOperatorLoc(), diag::err_expr_divide_by_zero, E);
|
return Error(E->getOperatorLoc(), diag::note_expr_divide_by_zero, E);
|
||||||
Result %= RHS;
|
Result %= RHS;
|
||||||
break;
|
break;
|
||||||
case BinaryOperator::Shl:
|
case BinaryOperator::Shl:
|
||||||
|
@ -818,7 +817,7 @@ bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
|
||||||
default:
|
default:
|
||||||
// Address, indirect, pre/post inc/dec, etc are not valid constant exprs.
|
// Address, indirect, pre/post inc/dec, etc are not valid constant exprs.
|
||||||
// See C99 6.6p3.
|
// See C99 6.6p3.
|
||||||
return Error(E->getOperatorLoc(), diag::err_expr_not_constant, E);
|
return Error(E->getOperatorLoc(), diag::note_invalid_subexpr_in_ice, E);
|
||||||
case UnaryOperator::Extension:
|
case UnaryOperator::Extension:
|
||||||
// FIXME: Should extension allow i-c-e extension expressions in its scope?
|
// FIXME: Should extension allow i-c-e extension expressions in its scope?
|
||||||
// If so, we could clear the diagnostic ID.
|
// If so, we could clear the diagnostic ID.
|
||||||
|
@ -883,11 +882,11 @@ bool IntExprEvaluator::HandleCast(CastExpr *E) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SubExpr->getType()->isRealFloatingType())
|
if (!SubExpr->getType()->isRealFloatingType())
|
||||||
return Error(E->getExprLoc(), diag::err_expr_not_constant, E);
|
return Error(E->getExprLoc(), diag::note_invalid_subexpr_in_ice, E);
|
||||||
|
|
||||||
APFloat F(0.0);
|
APFloat F(0.0);
|
||||||
if (!EvaluateFloat(SubExpr, F, Info))
|
if (!EvaluateFloat(SubExpr, F, Info))
|
||||||
return Error(E->getExprLoc(), diag::err_expr_not_constant, E);
|
return Error(E->getExprLoc(), diag::note_invalid_subexpr_in_ice, E);
|
||||||
|
|
||||||
// Determine whether we are converting to unsigned or signed.
|
// Determine whether we are converting to unsigned or signed.
|
||||||
bool DestSigned = DestType->isSignedIntegerType();
|
bool DestSigned = DestType->isSignedIntegerType();
|
||||||
|
|
Loading…
Reference in New Issue