forked from OSchip/llvm-project
Fix obvious shortcoming in the implementations of Evaluate for
integer __real__ and __imag__. Not sure how I missed this. llvm-svn: 65677
This commit is contained in:
parent
8a56e5c29b
commit
a1c7b6c5f6
|
@ -645,9 +645,7 @@ public:
|
|||
}
|
||||
|
||||
bool VisitChooseExpr(const ChooseExpr *E);
|
||||
bool VisitUnaryReal(const UnaryOperator *E) {
|
||||
return Visit(E->getSubExpr());
|
||||
}
|
||||
bool VisitUnaryReal(const UnaryOperator *E);
|
||||
bool VisitUnaryImag(const UnaryOperator *E);
|
||||
|
||||
private:
|
||||
|
@ -1192,7 +1190,25 @@ bool IntExprEvaluator::VisitChooseExpr(const ChooseExpr *E) {
|
|||
return Visit(EvalExpr);
|
||||
}
|
||||
|
||||
bool IntExprEvaluator::VisitUnaryReal(const UnaryOperator *E) {
|
||||
if (E->getSubExpr()->getType()->isAnyComplexType()) {
|
||||
APValue LV;
|
||||
if (!EvaluateComplex(E->getSubExpr(), LV, Info) || !LV.isComplexInt())
|
||||
return Error(E->getExprLoc(), diag::note_invalid_subexpr_in_ice, E);
|
||||
return Success(LV.getComplexIntReal(), E);
|
||||
}
|
||||
|
||||
return Visit(E->getSubExpr());
|
||||
}
|
||||
|
||||
bool IntExprEvaluator::VisitUnaryImag(const UnaryOperator *E) {
|
||||
if (E->getSubExpr()->getType()->isComplexIntegerType()) {
|
||||
APValue LV;
|
||||
if (!EvaluateComplex(E->getSubExpr(), LV, Info) || !LV.isComplexInt())
|
||||
return Error(E->getExprLoc(), diag::note_invalid_subexpr_in_ice, E);
|
||||
return Success(LV.getComplexIntImag(), E);
|
||||
}
|
||||
|
||||
if (!E->getSubExpr()->isEvaluatable(Info.Ctx))
|
||||
Info.EvalResult.HasSideEffects = true;
|
||||
return Success(0, E);
|
||||
|
|
|
@ -42,3 +42,8 @@ struct s {
|
|||
EVAL_EXPR(19, ((int)&*(char*)10 == 10 ? 1 : -1));
|
||||
|
||||
EVAL_EXPR(20, __builtin_constant_p(*((int*) 10), -1, 1));
|
||||
|
||||
EVAL_EXPR(21, (__imag__ 2i) == 2 ? 1 : -1);
|
||||
|
||||
EVAL_EXPR(22, (__real__ (2i+3)) == 3 ? 1 : -1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue