re PR c++/79672 (ICE with -Wduplicated-branches -fopenmp)
authorMarek Polacek <polacek@redhat.com>
Thu, 9 Mar 2017 09:53:03 +0000 (09:53 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 9 Mar 2017 09:53:03 +0000 (09:53 +0000)
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
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wduplicated-branches2.C
gcc/testsuite/g++.dg/warn/Wduplicated-branches3.C [new file with mode: 0644]
gcc/tree.c

index 752a5324b0dd75f76b3a8d4f95b0acbf71e4927b..006052bad27678206d7e89cdde63733f76fc9e8a 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-09  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/79672
+       * tree.c (inchash::add_expr): Handle TREE_VEC.
+
 2017-03-09  Martin Liska  <mliska@suse.cz>
 
        PR ipa/79764
index 2bfb55391bf2e3086a6f33dab4536bd233fada38..840eb1d26a74a3dde9e75828db12d10e4a78c6bf 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-09  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/79672
+       * g++.dg/warn/Wduplicated-branches2.C: Fix PR.
+       * g++.dg/warn/Wduplicated-branches3.C: New test.
+
 2017-03-09  Prachi Godbole  <prachi.godbole@imgtec.com>
 
        * gcc.target/mips/msa-bclri.c: Skip the test for -O0.
index 4da2d544a1cbaa1695a927fd2bee10960dd317e0..7e14c5fb6cd62dfd33e1b5c851085ef0c665a467 100644 (file)
@@ -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 (file)
index 0000000..26dab85
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/79672
+// { dg-do compile }
+// { dg-options "-Wduplicated-branches -fopenmp" }
+// { dg-require-effective-target fopenmp }
+
+template<int N> void foo()
+{
+  if (N > 0)
+  {
+#pragma omp parallel for
+    for (int i = 0; i < 10; ++i) ;
+  }
+}
+
+void bar()
+{
+  foo<0>();
+}
index 42c8a2ddd8a50106e87c92bf160431d8ea66cedc..8f87e7cfacb20285560d285cbd4fa44bccf53e74 100644 (file)
@@ -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