This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR c++/27451: ICE on invalid asm statement
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 22 May 2006 11:19:11 +0200 (CEST)
- Subject: [patch] Fix PR c++/27451: ICE on invalid asm statement
Compiling the following code with the C++ frontend causes an ICE
since GCC 3.4.0:
void foo()
{
asm("" ::: X);
}
bug.cc: In function 'void foo()':
bug.cc:3: error: expected string-literal before 'X'
bug.cc:3: error: expected `)' before 'X'
bug.cc:3: internal compiler error: tree check: expected string_cst, have
error_mark in expand_asm_operands, at stmt.c:696
Please submit a full bug report, [etc.]
The following patch adds a check in expand_asm_operands for invalid
clobbers. We already have a similar check a couple of lines below
for inputs.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline, 4.1 branch, and 4.0 branch?
Regards,
Volker
:ADDPATCH C++:
2006-05-15 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27451
* stmt.c (expand_asm_operands): Skip asm statement with erroneous
clobbers.
===================================================================
--- gcc/gcc/stmt.c (revision 113772)
+++ gcc/gcc/stmt.c (working copy)
@@ -693,8 +693,12 @@ expand_asm_operands (tree string, tree outputs,
CLEAR_HARD_REG_SET (clobbered_regs);
for (tail = clobbers; tail; tail = TREE_CHAIN (tail))
{
- const char *regname = TREE_STRING_POINTER (TREE_VALUE (tail));
+ const char *regname;
+ if (TREE_VALUE (tail) == error_mark_node)
+ return;
+ regname = TREE_STRING_POINTER (TREE_VALUE (tail));
+
i = decode_reg_name (regname);
if (i >= 0 || i == -4)
++nclobbers;
===================================================================
2006-05-15 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27451
* g++.dg/ext/asm9.C: New test.
===================================================================
--- gcc/gcc/testsuite/g++.dg/ext/asm9.C 2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/ext/asm9.C 2006-05-15 17:10:58 +0200
@@ -0,0 +1,7 @@
+// PR 27451
+// { dg-do compile }
+
+void foo()
+{
+ asm("" ::: X); // { dg-error "before" }
+}
===================================================================