]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/52247 (ICE with asm goto)
authorJakub Jelinek <jakub@redhat.com>
Tue, 14 Feb 2012 23:36:19 +0000 (00:36 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 14 Feb 2012 23:36:19 +0000 (00:36 +0100)
Backported from mainline
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.

From-SVN: r184244

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/asmgoto1.C [new file with mode: 0644]

index 4eb9ec48954e2ae418dadcf77a9ff711aa02d74a..c87567ef7f8e6d8e4ee0bbcff8934be6048e9c6f 100644 (file)
@@ -3,6 +3,10 @@
        Backported from mainline
        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.
+
        PR c/52181
        * decl.c (duplicate_decls): If olddecl has bigger DECL_ALIGN than
        newdecl, copy DECL_ALIGN to newdecl and or DECL_USER_ALIGN bits.
index a94b10f347ae71b5e8224ff3fe113042dca1238a..0760e9e23ca9164317d0cbef4e38f0cee6027786 100644 (file)
@@ -11886,8 +11886,17 @@ tsubst_copy_asm_operands (tree t, tree args, tsubst_flags_t complain,
   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);
index 2e19a3d73d510c8c679bdc95c9aab46dc0dd5684..d87feb9059c2a7781961cf5f902b03efca860268 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2012-02-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/52247
+       * g++.dg/template/asmgoto1.C: New test.
+
        PR c/52181
        * c-c++-common/pr52181.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/template/asmgoto1.C b/gcc/testsuite/g++.dg/template/asmgoto1.C
new file mode 100644 (file)
index 0000000..6a3cbce
--- /dev/null
@@ -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> ();
+}