re PR c++/86025 (ICE with -Wduplicated-branches and OpenMP critical)
authorJakub Jelinek <jakub@redhat.com>
Mon, 4 Jun 2018 07:27:52 +0000 (09:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 4 Jun 2018 07:27:52 +0000 (09:27 +0200)
PR c++/86025
* tree.c (inchash::add_expr): Handle IDENTIFIER_NODE.

* c-c++-common/gomp/pr86025.c: New test.

From-SVN: r261137

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/pr86025.c [new file with mode: 0644]
gcc/tree.c

index 4faeadc..3882e60 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/86025
+       * tree.c (inchash::add_expr): Handle IDENTIFIER_NODE.
+
 2018-06-03  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR tree-optimization/86034
index c3a9bca..7352e41 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/86025
+       * c-c++-common/gomp/pr86025.c: New test.
+
 2018-06-03  Andreas Schwab  <schwab@linux-m68k.org>
 
        * gcc.target/powerpc/altivec-7.c: Remove extra brace.
diff --git a/gcc/testsuite/c-c++-common/gomp/pr86025.c b/gcc/testsuite/c-c++-common/gomp/pr86025.c
new file mode 100644 (file)
index 0000000..c1c5079
--- /dev/null
@@ -0,0 +1,20 @@
+/* PR c++/86025 */
+/* { dg-do compile } */
+/* { dg-additional-options "-Wduplicated-branches" } */
+
+int i;
+
+void
+foo (int x)
+{
+  if (x)
+    {
+      #pragma omp critical (foo)
+      i++;
+    }
+  else
+    {
+      #pragma omp critical
+      i++;
+    }
+}
index 85ce993..2c75953 100644 (file)
@@ -7360,6 +7360,9 @@ add_expr (const_tree t, inchash::hash &hstate, unsigned int flags)
       for (i = 0; i < TREE_VEC_LENGTH (t); ++i)
        inchash::add_expr (TREE_VEC_ELT (t, i), hstate, flags);
       return;
+    case IDENTIFIER_NODE:
+      hstate.add_object (IDENTIFIER_HASH_VALUE (t));
+      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