From f22e586c69e634fe6a48c4062ebde0db4d94cd1c Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 25 Mar 2019 10:05:15 +0000 Subject: [PATCH] re PR middle-end/89790 (ICE segfault in operand_equal_p() at fold-const.c:3000 with -Wduplicated-cond since r269838) 2019-03-25 Richard Biener PR middle-end/89790 * fold-const.c (operand_equal_p): Revert last change with updated comment. * g++.dg/pr89790.C: New testcase. From-SVN: r269907 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr89790.C | 20 ++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/g++.dg/pr89790.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8ce3d7cd337..fd07440fe42 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-03-25 Richard Biener + + PR middle-end/89790 + * fold-const.c (operand_equal_p): Revert last change with + updated comment. + 2019-03-24 Segher Boessenkool * config/rs6000/rs6000.c (rs6000_legitimize_tls_address): Add REG_EQUAL diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 86ad2cb8487..c2884a67519 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2973,6 +2973,11 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) || TREE_TYPE (arg1) == error_mark_node) return 0; + /* Similar, if either does not have a type (like a template id), + they aren't equal. */ + if (!TREE_TYPE (arg0) || !TREE_TYPE (arg1)) + return 0; + /* We cannot consider pointers to different address space equal. */ if (POINTER_TYPE_P (TREE_TYPE (arg0)) && POINTER_TYPE_P (TREE_TYPE (arg1)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a4560af1d17..74b1483a0cb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-25 Richard Biener + + PR middle-end/89790 + * g++.dg/pr89790.C: New testcase. + 2019-03-24 Uroš Bizjak * gcc.target/i386/pr82281.c: Compile only for ia32 effective target. diff --git a/gcc/testsuite/g++.dg/pr89790.C b/gcc/testsuite/g++.dg/pr89790.C new file mode 100644 index 00000000000..c4d97664c0c --- /dev/null +++ b/gcc/testsuite/g++.dg/pr89790.C @@ -0,0 +1,20 @@ +// { dg-do compile } +// { dg-options "-Wduplicated-cond" } + +template +class a +{ + typedef a b; + template void c(); +}; +template template +void a::c() +{ + int f; + b g; + if (g == 0) + ; + else if (f) + { + } +} -- 2.30.2