re PR c++/81229 (ICE in c_tree_chain_next on aarch64)
authorNathan Sidwell <nathan@acm.org>
Fri, 30 Jun 2017 11:40:08 +0000 (11:40 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 30 Jun 2017 11:40:08 +0000 (11:40 +0000)
PR c++/81229
* name-lookup.c (do_pushdecl): Reset IDENTIFIER_TYPE when finding
a matching TYPE_DECL.

* g++.dg/lookup/pr81229.C: New.

From-SVN: r249835

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/pr81229.C [new file with mode: 0644]

index 40153aafea0997cedb542009b7b6dd3cd554ae23..38b63e4340385a577be675e36e6dedd4d4395424 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-30  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/81229
+       * name-lookup.c (do_pushdecl): Reset IDENTIFIER_TYPE when finding
+       a matching TYPE_DECL.
+
 2017-06-29  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * class.c (add_method): Change pair of errors to error + inform.
index 4beab850612e2dd4fb903ceeaf90d77e6ee70331..fcf06e0cf5b847efcdeb13855145fe6f79163331 100644 (file)
@@ -2354,9 +2354,13 @@ do_pushdecl (tree decl, bool is_friend)
          ; /* Ignore using decls here.  */
        else if (tree match = duplicate_decls (decl, *iter, is_friend))
          {
-           if (iter.hidden_p ()
-               && match != error_mark_node
-               && !DECL_HIDDEN_P (match))
+           if (match == error_mark_node)
+             ;
+           else if (TREE_CODE (match) == TYPE_DECL)
+             /* The IDENTIFIER will have the type referring to the
+                now-smashed TYPE_DECL, because ...?  Reset it.  */
+             SET_IDENTIFIER_TYPE_VALUE (name, TREE_TYPE (match));
+           else if (iter.hidden_p () && !DECL_HIDDEN_P (match))
              {
                /* Unhiding a previously hidden decl.  */
                tree head = iter.reveal_node (old);
index 274fced11a2294d70149c46d19f2f3a9c8333ac2..8a6311a6565941432e16f5e4d0a69adc30ddfb43 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-30  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/81229
+       * g++.dg/lookup/pr81229.C: New.
+
 2017-06-30  Martin Liska  <mliska@suse.cz>
 
        PR sanitizer/81021
diff --git a/gcc/testsuite/g++.dg/lookup/pr81229.C b/gcc/testsuite/g++.dg/lookup/pr81229.C
new file mode 100644 (file)
index 0000000..c9981c9
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/81229 GC ICE with stale pointed in identifier type.
+// { dg-additional-options "--param ggc-min-heapsize=0" }
+
+typedef unsigned L;
+typedef unsigned L;
+
+L l;