re PR middle-end/14289 (ICE in a register array)

PR middle-end/14289
	* c-typeck.c (c_mark_addressable): A register variable should
	be considered global if its not automatic, i.e. TREE_PUBLIC,
	TREE_STATIC or DECL_EXTERNAL.
	* function.c (put_var_into_stack): Call abort when placing a
	hard register into the stack, if x_parm_reg_stack_loc is NULL.

	* gcc.dg/pr14289-1.c: New test case.
	* gcc.dg/pr14289-2.c: Likewise.
	* gcc.dg/pr14289-3.c: Likewise.

From-SVN: r79127
This commit is contained in:
Roger Sayle 2004-03-08 21:56:36 +00:00 committed by Roger Sayle
parent 59f8a8be07
commit e697b20f79
7 changed files with 62 additions and 5 deletions

View File

@ -1,3 +1,12 @@
2004-03-08 Roger Sayle <roger@eyesopen.com>
PR middle-end/14289
* c-typeck.c (c_mark_addressable): A register variable should
be considered global if its not automatic, i.e. TREE_PUBLIC,
TREE_STATIC or DECL_EXTERNAL.
* function.c (put_var_into_stack): Call abort when placing a
hard register into the stack, if x_parm_reg_stack_loc is NULL.
2004-03-08 Ulrich Weigand <uweigand@de.ibm.com>
* config/s390/s390.md ("*extendqidi2_short_displ"): Add CC clobber.

View File

@ -2603,7 +2603,7 @@ c_mark_addressable (tree exp)
if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x)
&& DECL_NONLOCAL (x))
{
if (TREE_PUBLIC (x))
if (TREE_PUBLIC (x) || TREE_STATIC (x) || DECL_EXTERNAL (x))
{
error ("global register variable `%s' used in nested function",
IDENTIFIER_POINTER (DECL_NAME (x)));
@ -2614,7 +2614,7 @@ c_mark_addressable (tree exp)
}
else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
{
if (TREE_PUBLIC (x))
if (TREE_PUBLIC (x) || TREE_STATIC (x) || DECL_EXTERNAL (x))
{
error ("address of global register variable `%s' requested",
IDENTIFIER_POINTER (DECL_NAME (x)));

View File

@ -1430,8 +1430,9 @@ put_var_into_stack (tree decl, int rescan)
static void
put_reg_into_stack (struct function *function, rtx reg, tree type,
enum machine_mode promoted_mode, enum machine_mode decl_mode,
int volatile_p, unsigned int original_regno, int used_p, htab_t ht)
enum machine_mode promoted_mode,
enum machine_mode decl_mode, int volatile_p,
unsigned int original_regno, int used_p, htab_t ht)
{
struct function *func = function ? function : cfun;
rtx new = 0;
@ -1441,7 +1442,11 @@ put_reg_into_stack (struct function *function, rtx reg, tree type,
regno = REGNO (reg);
if (regno < func->x_max_parm_reg)
new = func->x_parm_reg_stack_loc[regno];
{
if (!func->x_parm_reg_stack_loc)
abort ();
new = func->x_parm_reg_stack_loc[regno];
}
if (new == 0)
new = assign_stack_local_1 (decl_mode, GET_MODE_SIZE (decl_mode), 0, func);

View File

@ -1,3 +1,10 @@
2004-03-08 Roger Sayle <roger@eyesopen.com>
PR middle-end/14289
* gcc.dg/pr14289-1.c: New test case.
* gcc.dg/pr14289-2.c: Likewise.
* gcc.dg/pr14289-3.c: Likewise.
2004-03-08 Eric Botcazou <ebotcazou@act-europe.fr>
* gcc.c-torture/execute/20040308-1.c: New test.

View File

@ -0,0 +1,12 @@
/* PR middle-end/14289 */
/* { dg-do compile { target i?86-*-* } } */
/* { dg-options "-O0" } */
register int a[2] asm("ebx");
void Nase(void)
{
int i=6;
a[i]=5; /* { dg-error "address of global" } */
}

View File

@ -0,0 +1,12 @@
/* PR middle-end/14289 */
/* { dg-do compile { target i?86-*-* } } */
/* { dg-options "-O0" } */
static register int a[2] asm("ebx"); /* { dg-error "multiple storage" } */
void Nase(void)
{
int i=6;
a[i]=5; /* { dg-error "address of global" } */
}

View File

@ -0,0 +1,12 @@
/* PR middle-end/14289 */
/* { dg-do compile { target i?86-*-* } } */
/* { dg-options "-O0" } */
extern register int a[2] asm("ebx"); /* { dg-error "multiple storage" } */
void Nase(void)
{
int i=6;
a[i]=5; /* { dg-error "address of global" } */
}