From: Jakub Jelinek Date: Thu, 8 Mar 2018 07:29:42 +0000 (+0100) Subject: re PR tree-optimization/84740 (ICE in build_constructors, at tree-switch-conversion... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce8b1a1f132aff97d670bd326dd89ae318cd3c68;p=gcc.git re PR tree-optimization/84740 (ICE in build_constructors, at tree-switch-conversion.c:965) PR tree-optimization/84740 * tree-switch-conversion.c (process_switch): Call build_constructors only if info.phi_count is non-zero. * gcc.dg/torture/pr84740.c: New test. From-SVN: r258354 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c96e895c3d8..39587da2e84 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2018-03-08 Jakub Jelinek + PR tree-optimization/84740 + * tree-switch-conversion.c (process_switch): Call build_constructors + only if info.phi_count is non-zero. + PR tree-optimization/84739 * tree-tailcall.c (find_tail_calls): Check call arguments against DECL_ARGUMENTS (current_function_decl) rather than diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f0ac96471a..a42a376c6df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-03-08 Jakub Jelinek + PR tree-optimization/84740 + * gcc.dg/torture/pr84740.c: New test. + PR tree-optimization/84739 * gcc.dg/pr84739.c: New test. diff --git a/gcc/testsuite/gcc.dg/torture/pr84740.c b/gcc/testsuite/gcc.dg/torture/pr84740.c new file mode 100644 index 00000000000..8fcc028298f --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr84740.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/84740 */ + +void +frobulate_for_gcc (unsigned int v) +{ + const char *s; + switch (v) + { + case 0: + s = "foo"; + break; + case 1: + s = "bar"; + break; + case 2: + s = "spam"; + break; + default: + s = (const char *) 0; + break; + } + if (!s) + __builtin_printf ("%s\n", s); +} diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index c2538908340..2da7068345c 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -1563,7 +1563,8 @@ process_switch (gswitch *swtch) gather_default_values (info.default_case_nonstandard ? gimple_switch_label (swtch, 1) : gimple_switch_default_label (swtch), &info); - build_constructors (swtch, &info); + if (info.phi_count) + build_constructors (swtch, &info); build_arrays (swtch, &info); /* Build the static arrays and assignments. */ gen_inbound_check (swtch, &info); /* Build the bounds check. */