diff options
-rw-r--r-- | lib/AST/ExprConstant.cpp | 11 | ||||
-rw-r--r-- | test/CXX/expr/expr.const/p2-0x.cpp | 6 | ||||
-rw-r--r-- | test/Sema/const-eval.c | 3 | ||||
-rw-r--r-- | test/SemaCXX/constant-expression.cpp | 2 |
4 files changed, 12 insertions, 10 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index eb34fc5fca..f88206cee7 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -1151,11 +1151,10 @@ static bool EvaluateAsBooleanCondition(const Expr *E, bool &Result, } template<typename T> -static bool HandleOverflow(EvalInfo &Info, const Expr *E, +static void HandleOverflow(EvalInfo &Info, const Expr *E, const T &SrcValue, QualType DestType) { - Info.Diag(E, diag::note_constexpr_overflow) + Info.CCEDiag(E, diag::note_constexpr_overflow) << SrcValue << DestType; - return false; } static bool HandleFloatToIntCast(EvalInfo &Info, const Expr *E, @@ -1169,7 +1168,7 @@ static bool HandleFloatToIntCast(EvalInfo &Info, const Expr *E, bool ignored; if (Value.convertToInteger(Result, llvm::APFloat::rmTowardZero, &ignored) & APFloat::opInvalidOp) - return HandleOverflow(Info, E, Value, DestType); + HandleOverflow(Info, E, Value, DestType); return true; } @@ -1181,7 +1180,7 @@ static bool HandleFloatToFloatCast(EvalInfo &Info, const Expr *E, if (Result.convert(Info.Ctx.getFloatTypeSemantics(DestType), APFloat::rmNearestTiesToEven, &ignored) & APFloat::opOverflow) - return HandleOverflow(Info, E, Value, DestType); + HandleOverflow(Info, E, Value, DestType); return true; } @@ -1204,7 +1203,7 @@ static bool HandleIntToFloatCast(EvalInfo &Info, const Expr *E, if (Result.convertFromAPInt(Value, Value.isSigned(), APFloat::rmNearestTiesToEven) & APFloat::opOverflow) - return HandleOverflow(Info, E, Value, DestType); + HandleOverflow(Info, E, Value, DestType); return true; } diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp index 054669ef78..9e6716d0b8 100644 --- a/test/CXX/expr/expr.const/p2-0x.cpp +++ b/test/CXX/expr/expr.const/p2-0x.cpp @@ -131,14 +131,14 @@ namespace IncompleteClassTypeAddr { namespace UndefinedBehavior { void f(int n) { switch (n) { - case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}} + case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}} expected-note {{previous case defined here}} case (int)0x80000000u: // ok case (int)10000000000ll: // expected-note {{here}} case (unsigned int)10000000000ll: // expected-error {{duplicate case value}} case (int)(unsigned)(long long)4.4e9: // ok - case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}} + case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}} expected-error {{duplicate case value '2147483647'}} expected-note {{previous case defined here}} case (int)((float)1e37 / 1e30): // ok - case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}} + case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}} expected-error {{duplicate case value '2147483647'}} break; } } diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index bc8b227ac8..16d028eaf6 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -131,3 +131,6 @@ EVAL_EXPR(49, &x < &x - 100 ? 1 : -1) // expected-error {{must have a constant s extern struct Test50S Test50; EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned)&Test50 + 10)) // expected-error {{must have a constant size}} + +// <rdar://problem/11874571> +EVAL_EXPR(51, 0 != (float)1e99) diff --git a/test/SemaCXX/constant-expression.cpp b/test/SemaCXX/constant-expression.cpp index c997f3c525..c06b6c03f1 100644 --- a/test/SemaCXX/constant-expression.cpp +++ b/test/SemaCXX/constant-expression.cpp @@ -115,7 +115,7 @@ int array2[recurse2]; // expected-warning {{variable length array}} expected-war namespace FloatConvert { typedef int a[(int)42.3]; typedef int a[(int)42.997]; - typedef int b[(int)4e10]; // expected-warning {{variable length}} expected-error {{variable length}} + typedef int b[(int)4e10]; // expected-warning {{variable length}} expected-warning {{size of static array must be an integer constant expression}} } // PR12626 |