OSDN Git Service

PR middle-end/14289
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Mar 2004 21:56:36 +0000 (21:56 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Mar 2004 21:56:36 +0000 (21:56 +0000)
* 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
gcc/c-typeck.c
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr14289-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr14289-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr14289-3.c [new file with mode: 0644]

index fa67744..8c7aae7 100644 (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.
index ffb4468..15cb6de 100644 (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)));
index b59707a..4fffcd8 100644 (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);
index 57c2eda..f0193f0 100644 (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.
diff --git a/gcc/testsuite/gcc.dg/pr14289-1.c b/gcc/testsuite/gcc.dg/pr14289-1.c
new file mode 100644 (file)
index 0000000..6529163
--- /dev/null
@@ -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 (file)
index 0000000..7530b46
--- /dev/null
@@ -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 (file)
index 0000000..7cfbf78
--- /dev/null
@@ -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" } */
+}
+