Commit 61637db3 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/70323 (missing error on integer overflow in constexpr function result converted to bool)

	PR c++/70323
	* constexpr.c (cxx_eval_constant_expression): Diagnose overflow
	on TREE_OVERFLOW constants.

	* g++.dg/cpp0x/constexpr-70323.C: New test.

From-SVN: r234438
parent 04833609
2016-03-23 Jakub Jelinek <jakub@redhat.com> 2016-03-23 Jakub Jelinek <jakub@redhat.com>
PR c++/70323
* constexpr.c (cxx_eval_constant_expression): Diagnose overflow
on TREE_OVERFLOW constants.
PR c++/70376 PR c++/70376
* cp-gimplify.c (genericize_omp_for_stmt): Don't walk OMP_FOR_CLAUSES * cp-gimplify.c (genericize_omp_for_stmt): Don't walk OMP_FOR_CLAUSES
for OMP_TASKLOOP here. for OMP_TASKLOOP here.
......
...@@ -3321,8 +3321,13 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -3321,8 +3321,13 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
} }
if (CONSTANT_CLASS_P (t)) if (CONSTANT_CLASS_P (t))
{ {
if (TREE_OVERFLOW (t) && (!flag_permissive || ctx->quiet)) if (TREE_OVERFLOW (t))
*overflow_p = true; {
if (!ctx->quiet)
permerror (input_location, "overflow in constant expression");
if (!flag_permissive || ctx->quiet)
*overflow_p = true;
}
return t; return t;
} }
......
2016-03-23 Jakub Jelinek <jakub@redhat.com>
PR c++/70323
* g++.dg/cpp0x/constexpr-70323.C: New test.
2016-03-23 Alexandre Oliva <aoliva@redhat.com> 2016-03-23 Alexandre Oliva <aoliva@redhat.com>
Jason Merrill <jason@redhat.com> Jason Merrill <jason@redhat.com>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
......
// PR c++/70323
// { dg-do compile { target c++11 } }
constexpr int overflow_if_0 (int i) { return __INT_MAX__ + !i; }
constexpr int overflow_if_1 (int i) { return __INT_MAX__ + i; }
constexpr bool i0_0 = overflow_if_0 (0); // { dg-error "overflow in constant expression" }
constexpr bool i0_1 = overflow_if_0 (1);
constexpr bool i1_0 = overflow_if_1 (0);
constexpr bool i1_1 = overflow_if_1 (1); // { dg-error "overflow in constant expression" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment