]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/89709 (ICE with constexpr and "-O")
authorJakub Jelinek <jakub@redhat.com>
Fri, 15 Mar 2019 09:23:11 +0000 (10:23 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 15 Mar 2019 09:23:11 +0000 (10:23 +0100)
PR c++/89709
* tree.c (inchash::add_expr): Strip any location wrappers.
* fold-const.c (operand_equal_p): Move stripping of location wrapper
after hash verification.

* g++.dg/cpp0x/constexpr-89709.C: New test.

From-SVN: r269702

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-89709.C [new file with mode: 0644]
gcc/tree.c

index 5bd943b27fe908d94c25f1197f4313e092dce6f4..d7a4f3832d7aaf96462f2ece765f1e78799716c4 100644 (file)
@@ -1,5 +1,10 @@
 2019-03-15  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/89709
+       * tree.c (inchash::add_expr): Strip any location wrappers.
+       * fold-const.c (operand_equal_p): Move stripping of location wrapper
+       after hash verification.
+
        PR debug/89704
        * dwarf2out.c (add_const_value_attribute): Return false for MINUS,
        SIGN_EXTEND and ZERO_EXTEND.
index dbc96798e656fafd613b92d3e7a9d901edd416b6..ec28b431eb8f499988deff99d73dc8bef9f6378c 100644 (file)
@@ -2942,9 +2942,6 @@ combine_comparisons (location_t loc,
 int
 operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
 {
-  STRIP_ANY_LOCATION_WRAPPER (arg0);
-  STRIP_ANY_LOCATION_WRAPPER (arg1);
-
   /* When checking, verify at the outermost operand_equal_p call that
      if operand_equal_p returns non-zero then ARG0 and ARG1 has the same
      hash value.  */
@@ -2967,6 +2964,9 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
        return 0;
     }
 
+  STRIP_ANY_LOCATION_WRAPPER (arg0);
+  STRIP_ANY_LOCATION_WRAPPER (arg1);
+
   /* If either is ERROR_MARK, they aren't equal.  */
   if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK
       || TREE_TYPE (arg0) == error_mark_node
index 8780192ddd2033ed2b9ccfaf826ebf559fc86432..4e267d3f04161b935705ea7fef30fc4335f8475d 100644 (file)
@@ -1,5 +1,8 @@
 2019-03-15  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/89709
+       * g++.dg/cpp0x/constexpr-89709.C: New test.
+
        PR debug/89704
        * gcc.dg/debug/pr89704.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-89709.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-89709.C
new file mode 100644 (file)
index 0000000..30b319a
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/89709
+// { dg-do compile { target c++11 } }
+// { dg-options "-O" }
+
+struct A { int i; };
+A a;
+
+constexpr int *
+foo ()
+{
+  return &a.i;
+}
+
+bool
+bar ()
+{
+  return foo () == &a.i;
+}
index 02721cfc8a04b8e48241611cba03b44972354010..d061a0422ff0d4eff14de0081ae71ee6e563e118 100644 (file)
@@ -7743,6 +7743,8 @@ add_expr (const_tree t, inchash::hash &hstate, unsigned int flags)
       return;
     }
 
+  STRIP_ANY_LOCATION_WRAPPER (t);
+
   if (!(flags & OEP_ADDRESS_OF))
     STRIP_NOPS (t);