From: Jakub Jelinek Date: Tue, 14 Feb 2012 23:36:19 +0000 (+0100) Subject: backport: re PR c++/52247 (ICE with asm goto) X-Git-Tag: releases/gcc-4.6.3~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0441deffd27c1562504ab8a6c653c1c910368de4;p=thirdparty%2Fgcc.git backport: re PR c++/52247 (ICE with asm goto) Backported from mainline 2012-02-14 Jakub Jelinek 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4eb9ec48954e..c87567ef7f8e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -3,6 +3,10 @@ Backported from mainline 2012-02-14 Jakub Jelinek + 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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a94b10f347ae..0760e9e23ca9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2e19a3d73d51..d87feb9059c2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,9 @@ Backported from mainline 2012-02-14 Jakub Jelinek + 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 index 000000000000..6a3cbcef4eeb --- /dev/null +++ b/gcc/testsuite/g++.dg/template/asmgoto1.C @@ -0,0 +1,18 @@ +// PR c++/52247 +// { dg-do compile } + +template +bool +bar () +{ + __asm goto ("" : : : : lab); + return true; +lab: + return false; +} + +bool +foo () +{ + return bar<0> (); +}