diff mbox series

[middle-end/82577] Fix DECL_ASSEMBLER_NAME ICE

Message ID 322bb35a-af84-ae6b-7a95-c6f464aed8bb@acm.org
State New
Headers show
Series [middle-end/82577] Fix DECL_ASSEMBLER_NAME ICE | expand

Commit Message

Nathan Sidwell Oct. 17, 2017, 3:41 p.m. UTC
This fixes a new ICE I caused by breaking out HAS_DECL_ASSEMBLER_NAME_P 
from DECL_ASSEMBLER_NAME_SET_P.  alias.c needs to check it.  As it's 
doing explicit HAS and SET checking, it might as well use the RAW 
accessor too.

Committing as obvious.

nathan
diff mbox series

Patch

2017-10-17  Nathan Sidwell  <nathan@acm.org>

	gcc/
	PR middle-end/82577
	* alias.c (compare_base_decls): Check HAS_DECL_ASSEMBLER_NAME_P,
	use DECL_ASSEMBLER_NAME_RAW.

	gcc/testsuite/
	PR middle-end/82577
	* g++.dg/opt/pr82577.C: New.

Index: alias.c
===================================================================
--- alias.c	(revision 253818)
+++ alias.c	(working copy)
@@ -2047,13 +2047,15 @@  compare_base_decls (tree base1, tree bas
     return 1;
 
   /* If we have two register decls with register specification we
-     cannot decide unless their assembler name is the same.  */
+     cannot decide unless their assembler names are the same.  */
   if (DECL_REGISTER (base1)
       && DECL_REGISTER (base2)
+      && HAS_DECL_ASSEMBLER_NAME_P (base1)
+      && HAS_DECL_ASSEMBLER_NAME_P (base2)
       && DECL_ASSEMBLER_NAME_SET_P (base1)
       && DECL_ASSEMBLER_NAME_SET_P (base2))
     {
-      if (DECL_ASSEMBLER_NAME (base1) == DECL_ASSEMBLER_NAME (base2))
+      if (DECL_ASSEMBLER_NAME_RAW (base1) == DECL_ASSEMBLER_NAME_RAW (base2))
 	return 1;
       return -1;
     }
Index: testsuite/g++.dg/opt/pr82577.C
===================================================================
--- testsuite/g++.dg/opt/pr82577.C	(revision 0)
+++ testsuite/g++.dg/opt/pr82577.C	(working copy)
@@ -0,0 +1,17 @@ 
+// { dg-additional-options "-O2" }
+// PR c++/82577 ICE when optimizing
+
+class a {
+public:
+  int *b();
+};
+struct c {
+  int d;
+  a e;
+} f;
+void fn1(register c *g) {
+  register int *h;
+  do
+    (h) = g->e.b() + (g)->d;
+  while (&f);
+}