This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR c/5656
- From: "Eric Botcazou" <ebotcazou at libertysurf dot fr>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 21 Feb 2002 23:15:57 +0100
- Subject: [PATCH] Fix PR c/5656
Hello,
This ICE is caused by a nasty interaction between old-style C functions,
inlinization and code for handling a special case in
expr.c:expand_assignment() line 3782 and below, which bypasses the regular
treatment.
/* compile with -finline-functions */
char foo1(char c)
{
return c;
}
char foo2(c)
char c;
{
return c;
}
int bar(int);
void quus(int c)
{
char a;
a = foo1(bar(c)); /* ok */
a = foo2(bar(c)); /* ICE in emit_move_insn() */
}
The initialization of the c parameter of foo1() is inlined as:
VAR_DECL (QImode) <- NOP_EXPR <- NOP_EXPR <- CALL_EXPR (SImode)
while the initialization of the c parameter of foo2() is inlined as:
VAR_DECL (QImode) <- CALL_EXPR (SImode)
This latter case is caught by the special code in expand_assignment() line
3782 and below, which redirects it to a mere emit_move_insn(),
hence the ICE.
2002-02-21 Eric Botcazou <ebotcazou@multimania.com>
expr.c (expand_assignment): Don't assume the
machine modes are the same when bypassing the
regular treatment for a CALL_EXPR.
--- gcc/expr.c 19 Feb 2002 02:53:26 -0000 1.420
+++ gcc/expr.c 21 Feb 2002 00:17:03 -0000
@@ -3799,7 +3804,9 @@
&& GET_MODE (to_rtx) != GET_MODE (value))
value = convert_memory_address (GET_MODE (to_rtx), value);
#endif
- emit_move_insn (to_rtx, value);
+ /* Machine modes may not be the same, e.g if TO is a VAR_DECL
+ coming from a parameter of an inlined old-style C function. */
+ convert_move (to_rtx, value, TREE_UNSIGNED (TREE_TYPE (from)));
}
preserve_temp_slots (to_rtx);
free_temp_slots ();
/* PR c/5656 */
/* { dg-do compile } */
/* { dg-options "-finline-functions" } */
/* Verify that GCC converts types for
inlined old-style C functions. */
char foo(c)
char c;
{
return c;
}
int bar(int);
void quus(int c)
{
char a;
a = foo(bar(c));
}
--
Eric Botcazou
ebotcazou@multimania.com