From 410a590c2a718861487e2fc354da02c1394bbcb1 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 9 Mar 2017 09:53:03 +0000 Subject: [PATCH] re PR c++/79672 (ICE with -Wduplicated-branches -fopenmp) PR c++/79672 * tree.c (inchash::add_expr): Handle TREE_VEC. * g++.dg/warn/Wduplicated-branches2.C: Fix PR. * g++.dg/warn/Wduplicated-branches3.C: New test. From-SVN: r245996 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 6 ++++++ .../g++.dg/warn/Wduplicated-branches2.C | 2 +- .../g++.dg/warn/Wduplicated-branches3.C | 18 ++++++++++++++++++ gcc/tree.c | 4 ++++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/warn/Wduplicated-branches3.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 752a5324b0d..006052bad27 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-03-09 Marek Polacek + + PR c++/79672 + * tree.c (inchash::add_expr): Handle TREE_VEC. + 2017-03-09 Martin Liska PR ipa/79764 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2bfb55391bf..840eb1d26a7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-03-09 Marek Polacek + + PR c++/79672 + * g++.dg/warn/Wduplicated-branches2.C: Fix PR. + * g++.dg/warn/Wduplicated-branches3.C: New test. + 2017-03-09 Prachi Godbole * gcc.target/mips/msa-bclri.c: Skip the test for -O0. diff --git a/gcc/testsuite/g++.dg/warn/Wduplicated-branches2.C b/gcc/testsuite/g++.dg/warn/Wduplicated-branches2.C index 4da2d544a1c..7e14c5fb6cd 100644 --- a/gcc/testsuite/g++.dg/warn/Wduplicated-branches2.C +++ b/gcc/testsuite/g++.dg/warn/Wduplicated-branches2.C @@ -1,4 +1,4 @@ -// PR c/6427 +// PR c/64279 // { dg-do compile { target c++11 } } // { dg-options "-Wduplicated-branches" } diff --git a/gcc/testsuite/g++.dg/warn/Wduplicated-branches3.C b/gcc/testsuite/g++.dg/warn/Wduplicated-branches3.C new file mode 100644 index 00000000000..26dab855a56 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wduplicated-branches3.C @@ -0,0 +1,18 @@ +// PR c++/79672 +// { dg-do compile } +// { dg-options "-Wduplicated-branches -fopenmp" } +// { dg-require-effective-target fopenmp } + +template void foo() +{ + if (N > 0) + { +#pragma omp parallel for + for (int i = 0; i < 10; ++i) ; + } +} + +void bar() +{ + foo<0>(); +} diff --git a/gcc/tree.c b/gcc/tree.c index 42c8a2ddd8a..8f87e7cfacb 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7865,6 +7865,10 @@ add_expr (const_tree t, inchash::hash &hstate, unsigned int flags) inchash::add_expr (tsi_stmt (i), hstate, flags); return; } + case TREE_VEC: + for (int i = 0; i < TREE_VEC_LENGTH (t); ++i) + inchash::add_expr (TREE_VEC_ELT (t, i), hstate, flags); + return; case FUNCTION_DECL: /* When referring to a built-in FUNCTION_DECL, use the __builtin__ form. Otherwise nodes that compare equal according to operand_equal_p might -- 2.30.2