Jakub Jelinek wrote:
On Tue, Dec 18, 2012 at 04:40:10PM +0100, Tobias Burnus wrote:
Looks mostly okay, however, I fear that for
subroutine foo()
character(len=:), allocatable :: str
allocate(str, stat=istat)
end subroutine foo
compiled with "-fno-automatic", gfortran will still generate the
non-GFC_PREFIX-mangled string.
That doesn't compile:
Error: Allocate-object at (1) with a deferred type parameter requires either a
type-spec or SOURCE tag or a MOLD tag
Sorry for the bad example. I added the allocate just to mark the
variable as used (otherwise no decl is generated); but my cut-down
example was wrong. Try:
subroutine foo()
character(len=:), allocatable :: str
print *, allocated(str)
end subroutine foo
Or one of the examples from PR55733. The example above gives currently
(w/o your patch):
static character(kind=1)[1:.str] * str = 0B;
integer(kind=4) .str;
Where would be TREE_STATIC set on the length variable with -fno-automatic,
and on which testcase?
As written, TREE_STATIC is currently not set (which is a bug, cf.
PR55733); I think one needs a patch like:
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1107,3 +1107,4 @@ gfc_create_string_length (gfc_symbol * sym)
- if (sym->attr.save || sym->ns->proc_name->attr.flavor == FL_MODULE)
+ if (sym->attr.save || sym->ns->proc_name->attr.flavor == FL_MODULE
+ || gfc_option.flag_max_stack_var_size == 0)
TREE_STATIC (length) = 1;
Tobias