This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] Fix ICE with asm goto in template (PR c++/52247)


Hi!

We weren't transforming the asm goto LABEL_DECLs at all, while
when in LABEL_EXPR or in goto stmt they are remapped.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2012-02-14  Jakub Jelinek  <jakub@redhat.com>

	PR c++/52247
	* pt.c (tsubst_copy_asm_operands): For LABEL_DECL values call
	lookup_label on label's name and set TREE_USED.

	* g++.dg/template/asmgoto1.C: New test.

--- gcc/cp/pt.c.jj	2012-02-12 15:46:29.000000000 +0100
+++ gcc/cp/pt.c	2012-02-14 16:07:45.491634908 +0100
@@ -12612,8 +12612,17 @@ tsubst_copy_asm_operands (tree t, tree a
   if (purpose)
     purpose = RECUR (purpose);
   value = TREE_VALUE (t);
-  if (value && TREE_CODE (value) != LABEL_DECL)
-    value = RECUR (value);
+  if (value)
+    {
+      if (TREE_CODE (value) != LABEL_DECL)
+	value = RECUR (value);
+      else
+	{
+	  value = lookup_label (DECL_NAME (value));
+	  gcc_assert (TREE_CODE (value) == LABEL_DECL);
+	  TREE_USED (value) = 1;
+	}
+    }
   chain = TREE_CHAIN (t);
   if (chain && chain != void_type_node)
     chain = RECUR (chain);
--- gcc/testsuite/g++.dg/template/asmgoto1.C.jj	2012-02-14 16:25:30.102192552 +0100
+++ gcc/testsuite/g++.dg/template/asmgoto1.C	2012-02-14 16:25:21.000000000 +0100
@@ -0,0 +1,18 @@
+// PR c++/52247
+// { dg-do compile }
+
+template <int N>
+bool
+bar ()
+{
+  __asm goto ("" : : : : lab);
+  return true;
+lab:
+  return false;
+}
+
+bool
+foo ()
+{
+  return bar<0> ();
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]