From 20b11fd41a51d669eec3601571e21e0081f5c5e0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 4 Jun 2018 09:27:52 +0200 Subject: [PATCH] re PR c++/86025 (ICE with -Wduplicated-branches and OpenMP critical) PR c++/86025 * tree.c (inchash::add_expr): Handle IDENTIFIER_NODE. * c-c++-common/gomp/pr86025.c: New test. From-SVN: r261137 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/gomp/pr86025.c | 20 ++++++++++++++++++++ gcc/tree.c | 3 +++ 4 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/gomp/pr86025.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4faeadc8a47..3882e6098cf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-06-04 Jakub Jelinek + + PR c++/86025 + * tree.c (inchash::add_expr): Handle IDENTIFIER_NODE. + 2018-06-03 Eric Botcazou PR tree-optimization/86034 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c3a9bcaf176..7352e41c3fc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-04 Jakub Jelinek + + PR c++/86025 + * c-c++-common/gomp/pr86025.c: New test. + 2018-06-03 Andreas Schwab * 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 index 00000000000..c1c50799413 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr86025.c @@ -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++; + } +} diff --git a/gcc/tree.c b/gcc/tree.c index 85ce99373db..2c75953542b 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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 -- 2.30.2