re PR c++/68362 (ICE: tree check: expected integer_cst, have nop_expr in get_val, at tree.h:5157)

PR c++/68362
	* c-common.c (check_case_bounds): Fold low and high cases.

	* g++.dg/delayedfold/switch-1.C: New test.

From-SVN: r230435
This commit is contained in:
Marek Polacek 2015-11-16 20:16:57 +00:00 committed by Marek Polacek
parent 3e6ab82844
commit 0f62c7a0cc
4 changed files with 33 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2015-11-16 Marek Polacek <polacek@redhat.com>
PR c++/68362
* c-common.c (check_case_bounds): Fold low and high cases.
2015-11-16 Marek Polacek <polacek@redhat.com> 2015-11-16 Marek Polacek <polacek@redhat.com>
* c-ada-spec.c (dump_ada_template): Use RECORD_OR_UNION_TYPE_P. * c-ada-spec.c (dump_ada_template): Use RECORD_OR_UNION_TYPE_P.

View File

@ -3769,6 +3769,10 @@ check_case_bounds (location_t loc, tree type, tree orig_type,
min_value = TYPE_MIN_VALUE (orig_type); min_value = TYPE_MIN_VALUE (orig_type);
max_value = TYPE_MAX_VALUE (orig_type); max_value = TYPE_MAX_VALUE (orig_type);
/* We'll really need integer constants here. */
case_low = fold (case_low);
case_high = fold (case_high);
/* Case label is less than minimum for type. */ /* Case label is less than minimum for type. */
if (tree_int_cst_compare (case_low, min_value) < 0 if (tree_int_cst_compare (case_low, min_value) < 0
&& tree_int_cst_compare (case_high, min_value) < 0) && tree_int_cst_compare (case_high, min_value) < 0)

View File

@ -1,3 +1,8 @@
2015-11-16 Marek Polacek <polacek@redhat.com>
PR c++/68362
* g++.dg/delayedfold/switch-1.C: New test.
2015-11-16 Steven G. Kargl <kargl@gcc.gnu.org> 2015-11-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/58027 PR fortran/58027

View File

@ -0,0 +1,19 @@
// PR c++/68362
// { dg-do compile { target c++11 } }
enum class A { foo };
enum E { bar };
void
fn1 (const A a)
{
switch (a)
case A::foo:;
}
void
fn2 (E e)
{
switch (e)
case bar:;
}