]> gcc.gnu.org Git - gcc.git/commitdiff
re PR fortran/20361 (-fmax-stack-var-size=N not working for equivalence)
authorTobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
Sat, 12 Mar 2005 21:44:44 +0000 (22:44 +0100)
committerTobias Schlüter <tobi@gcc.gnu.org>
Sat, 12 Mar 2005 21:44:44 +0000 (22:44 +0100)
fortran/
PR fortran/20361
* trans-array.c (gfc_stack_space_left): Remove unused variable.
(gfc_can_put_var_on_stack): Move to trans-decl.c, remove #if 0'ed
code.
* trans-array.h (gfc_stack_space_left, gfc_can_put_var_on_stack):
Remove declaration / prototype.
* trans-common.c (build_equiv_decl): Give union a name.  Check if
it can be put on the stack.
* trans-decl.c (gfc_stack_space_left): Move function here.
(gfc_build_qualified_array): Fix comment typo.
* trans.h (gfc_put_var_on_stack): Add prototype.

testsuite/
PR fortran/20361
* gfortran.dg/largeequiv_1.f90: New test.

From-SVN: r96352

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/fortran/trans-array.h
gcc/fortran/trans-common.c
gcc/fortran/trans-decl.c
gcc/fortran/trans.h
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/largeequiv_1.f90 [new file with mode: 0644]

index 63b9cd1ccbf155c01b0b7cdbd78c75cf24201777..510789120e4075864230c542faacb2659987bf3c 100644 (file)
@@ -1,3 +1,17 @@
+2005-03-12  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       PR fortran/20361
+       * trans-array.c (gfc_stack_space_left): Remove unused variable.
+       (gfc_can_put_var_on_stack): Move to trans-decl.c, remove #if 0'ed
+       code.
+       * trans-array.h (gfc_stack_space_left, gfc_can_put_var_on_stack):
+       Remove declaration / prototype.
+       * trans-common.c (build_equiv_decl): Give union a name.  Check if
+       it can be put on the stack.
+       * trans-decl.c (gfc_stack_space_left): Move function here.
+       (gfc_build_qualified_array): Fix comment typo.
+       * trans.h (gfc_put_var_on_stack): Add prototype.
+
 2005-03-11  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * Make-lang.in (fortran-warn): Set to $(STRICT_WARN) -Wno-error.
index a97bcc593a371b4cb3318791be67d7ead79829c6..bd77eb46850a0710ecc71438428d8b1c32f9c32a 100644 (file)
@@ -99,43 +99,6 @@ static gfc_ss *gfc_walk_subexpr (gfc_ss *, gfc_expr *);
 static gfc_ss gfc_ss_terminator_var;
 gfc_ss * const gfc_ss_terminator = &gfc_ss_terminator_var;
 
-unsigned HOST_WIDE_INT gfc_stack_space_left;
-
-
-/* Returns true if a variable of specified size should go on the stack.  */
-
-int
-gfc_can_put_var_on_stack (tree size)
-{
-  unsigned HOST_WIDE_INT low;
-
-  if (!INTEGER_CST_P (size))
-    return 0;
-
-  if (gfc_option.flag_max_stack_var_size < 0)
-    return 1;
-
-  if (TREE_INT_CST_HIGH (size) != 0)
-    return 0;
-
-  low = TREE_INT_CST_LOW (size);
-  if (low > (unsigned HOST_WIDE_INT) gfc_option.flag_max_stack_var_size)
-    return 0;
-
-/* TODO: Set a per-function stack size limit.  */
-#if 0
-  /* We should be a bit more clever with array temps.  */
-  if (gfc_option.flag_max_function_vars_size >= 0)
-    {
-      if (low > gfc_stack_space_left)
-       return 0;
-
-      gfc_stack_space_left -= low;
-    }
-#endif
-
-  return 1;
-}
 
 static tree
 gfc_array_dataptr_type (tree desc)
index b4407693909bba848ba57f3adc523fd6a4fab988..faaaf5ade4b082b29ef18123dfcc589fc8b73368 100644 (file)
@@ -95,11 +95,6 @@ tree gfc_conv_array_stride (tree, int);
 tree gfc_conv_array_lbound (tree, int);
 tree gfc_conv_array_ubound (tree, int);
 
-/* The remaining space available for stack variables.  */
-extern unsigned HOST_WIDE_INT gfc_stack_space_left;
-/* Returns true if a variable of specified size should go on the stack.  */
-int gfc_can_put_var_on_stack (tree);
-
 /* Build expressions for accessing components of an array descriptor.  */
 tree gfc_conv_descriptor_data (tree);
 tree gfc_conv_descriptor_offset (tree);
index 35ea80120344b17f4512457baebb82c875736dea..c62d68d9b934f8add9ade302e1f6db1fc66105d3 100644 (file)
@@ -252,6 +252,8 @@ static tree
 build_equiv_decl (tree union_type, bool is_init)
 {
   tree decl;
+  char name[15];
+  static int serial = 0;
 
   if (is_init)
     {
@@ -260,10 +262,13 @@ build_equiv_decl (tree union_type, bool is_init)
       return decl;
     }
 
-  decl = build_decl (VAR_DECL, NULL, union_type);
+  snprintf (name, sizeof (name), "equiv.%d", serial++);
+  decl = build_decl (VAR_DECL, get_identifier (name), union_type);
   DECL_ARTIFICIAL (decl) = 1;
+  DECL_IGNORED_P (decl) = 1;
 
-  DECL_COMMON (decl) = 1;
+  if (!gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl)))
+    TREE_STATIC (decl) = 1;
 
   TREE_ADDRESSABLE (decl) = 1;
   TREE_USED (decl) = 1;
index b81b9862207b82acb2e8bd7d2e8677c4a92a9800..08dd72af697042ca7223e5223955ab34b0899805 100644 (file)
@@ -317,6 +317,32 @@ gfc_sym_mangled_function_id (gfc_symbol * sym)
 }
 
 
+/* Returns true if a variable of specified size should go on the stack.  */
+
+int
+gfc_can_put_var_on_stack (tree size)
+{
+  unsigned HOST_WIDE_INT low;
+
+  if (!INTEGER_CST_P (size))
+    return 0;
+
+  if (gfc_option.flag_max_stack_var_size < 0)
+    return 1;
+
+  if (TREE_INT_CST_HIGH (size) != 0)
+    return 0;
+
+  low = TREE_INT_CST_LOW (size);
+  if (low > (unsigned HOST_WIDE_INT) gfc_option.flag_max_stack_var_size)
+    return 0;
+
+/* TODO: Set a per-function stack size limit.  */
+
+  return 1;
+}
+
+
 /* Finish processing of a declaration and install its initial value.  */
 
 static void
@@ -533,7 +559,7 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
 
 
 /* For some dummy arguments we don't use the actual argument directly.
-   Instead we create a local decl and use that.  This allows us to preform
+   Instead we create a local decl and use that.  This allows us to perform
    initialization, and construct full type information.  */
 
 static tree
index f16e23ccff5543c4a68e52083a3a36fddf244d69..aad878f34f6ba33977ddfdd5437805488ebf1911 100644 (file)
@@ -391,6 +391,9 @@ void gfc_shadow_sym (gfc_symbol *, tree, gfc_saved_var *);
 /* Restore the original variable.  */
 void gfc_restore_sym (gfc_symbol *, gfc_saved_var *);
 
+/* Returns true if a variable of specified size should go on the stack.  */
+int gfc_can_put_var_on_stack (tree);
+
 /* Allocate the lang-spcific part of a decl node.  */
 void gfc_allocate_lang_decl (tree);
 
index d7c751d42e2a272d84e6b9f83b99092a34b77b8b..cdef890555026b9a95045e24596399451bf1283e 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-12  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       PR fortran/20361
+       * gfortran.dg/largeequiv_1.f90: New test.
+
 2005-03-12  Geoffrey Keating  <geoffk@apple.com>
 
        * gcc.dg/ucnid-1.c: New.
diff --git a/gcc/testsuite/gfortran.dg/largeequiv_1.f90 b/gcc/testsuite/gfortran.dg/largeequiv_1.f90
new file mode 100644 (file)
index 0000000..39b1f81
--- /dev/null
@@ -0,0 +1,13 @@
+! { dg-do run }
+! PR 20361 : We didn't check if a large equivalence actually fit on
+! the stack, and therefore segfaulted at execution time
+subroutine test
+integer i(1000000), j
+equivalence (i(50), j)
+
+j = 1
+if (i(50) /= j) call abort()
+end subroutine test
+
+call test
+end
This page took 0.088081 seconds and 5 git commands to generate.