From 7d282ac0c38edc8fe58e3268eb8afb30fe18e4aa Mon Sep 17 00:00:00 2001 From: sayle Date: Mon, 8 Mar 2004 21:56:36 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79127 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 9 +++++++++ gcc/c-typeck.c | 4 ++-- gcc/function.c | 11 ++++++++--- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gcc.dg/pr14289-1.c | 12 ++++++++++++ gcc/testsuite/gcc.dg/pr14289-2.c | 12 ++++++++++++ gcc/testsuite/gcc.dg/pr14289-3.c | 12 ++++++++++++ 7 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr14289-1.c create mode 100644 gcc/testsuite/gcc.dg/pr14289-2.c create mode 100644 gcc/testsuite/gcc.dg/pr14289-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fa67744..8c7aae7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2004-03-08 Roger Sayle + + 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 * config/s390/s390.md ("*extendqidi2_short_displ"): Add CC clobber. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index ffb4468..15cb6de 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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))); diff --git a/gcc/function.c b/gcc/function.c index b59707a..4fffcd8 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 57c2eda..f0193f0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2004-03-08 Roger Sayle + + 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 * gcc.c-torture/execute/20040308-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr14289-1.c b/gcc/testsuite/gcc.dg/pr14289-1.c new file mode 100644 index 0000000..6529163 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr14289-1.c @@ -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" } */ +} + diff --git a/gcc/testsuite/gcc.dg/pr14289-2.c b/gcc/testsuite/gcc.dg/pr14289-2.c new file mode 100644 index 0000000..7530b46 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr14289-2.c @@ -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" } */ +} + diff --git a/gcc/testsuite/gcc.dg/pr14289-3.c b/gcc/testsuite/gcc.dg/pr14289-3.c new file mode 100644 index 0000000..7cfbf78 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr14289-3.c @@ -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" } */ +} + -- 2.7.4