Jakub Jelinek <jakub@redhat.com>
Janus Weil <janus@gcc.gnu.org>
PR fortran/55636
PR fortran/55733
* gfortran.h (GFC_PREFIX): Define.
* trans-decl.c (gfc_create_string_length): For VAR_DECLs that
will be TREE_STATIC, use GFC_PREFIX to mangle the names. Handle
-fno-automatic
(gfc_trans_deferred_vars): Don't free variables SAVEd via
-fno-automatic.
2012-12-19 Tobias Burnus <burnus@net-b.de>
PR fortran/55733
* gfortran.dg/save_5.f90: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194604
138bc75d-0d04-0410-961f-
82ee72b054a4
+2012-12-19 Tobias Burnus <burnus@net-b.de>
+ Jakub Jelinek <jakub@redhat.com>
+ Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/55636
+ PR fortran/55733
+ * gfortran.h (GFC_PREFIX): Define.
+ * trans-decl.c (gfc_create_string_length): For VAR_DECLs that
+ will be TREE_STATIC, use GFC_PREFIX to mangle the names. Handle
+ -fno-automatic
+ (gfc_trans_deferred_vars): Don't free variables SAVEd via
+ -fno-automatic.
+
2012-12-16 Tobias Burnus <burnus@net-b.de>
PR fortran/55197
#define PREFIX(x) "_gfortran_" x
#define PREFIX_LEN 10
+/* A prefix for internal variables, which are not user-visible. */
+#if !defined (NO_DOT_IN_LABEL)
+# define GFC_PREFIX(x) "_F." x
+#elif !defined (NO_DOLLAR_IN_LABEL)
+# define GFC_PREFIX(x) "_F$" x
+#else
+# define GFC_PREFIX(x) "_F_" x
+#endif
+
#define BLANK_COMMON_NAME "__BLNK__"
/* Macro to initialize an mstring structure. */
tree length;
const char *name;
- /* Also prefix the mangled name. */
- if (sym->module)
+ bool static_length = sym->attr.save
+ || sym->ns->proc_name->attr.flavor == FL_MODULE
+ || gfc_option.flag_max_stack_var_size == 0;
+
+ /* Also prefix the mangled name. We need to call GFC_PREFIX for static
+ variables as some systems do not support the "." in the assembler name.
+ For nonstatic variables, the "." does not appear in assembler. */
+ if (static_length)
+ {
+ if (sym->module)
+ name = gfc_get_string (GFC_PREFIX ("%s_MOD_%s"), sym->module,
+ sym->name);
+ else
+ name = gfc_get_string (GFC_PREFIX ("%s"), sym->name);
+ }
+ else if (sym->module)
name = gfc_get_string (".__%s_MOD_%s", sym->module, sym->name);
else
name = gfc_get_string (".%s", sym->name);
sym->ts.u.cl->backend_decl = length;
- if (sym->attr.save || sym->ns->proc_name->attr.flavor == FL_MODULE)
+ if (static_length)
TREE_STATIC (length) = 1;
if (sym->ns->proc_name->attr.flavor == FL_MODULE
|| (sym->ts.type == BT_CLASS
&& CLASS_DATA (sym)->attr.allocatable)))
{
- if (!sym->attr.save)
+ if (!sym->attr.save && gfc_option.flag_max_stack_var_size != 0)
{
tree descriptor = NULL_TREE;
+2012-12-19 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/55733
+ * gfortran.dg/save_5.f90: New.
+
2012-12-18 Jakub Jelinek <jakub@redhat.com>
PR c/39464
--- /dev/null
+! { dg-do run }
+! { dg-options "-fno-automatic" }
+!
+! PR fortran/55733
+!
+! Check that -fno-automatic makes the local variable SAVEd
+!
+
+! Scalar allocatable
+subroutine foo(i)
+ integer :: i
+ integer, allocatable :: j
+ if (i == 1) j = 42
+ if (.not. allocated (j)) call abort ()
+ if (j /= 42) call abort ()
+end
+
+! Deferred-length string scalar
+subroutine bar()
+ logical, save :: first = .true.
+ character(len=:), allocatable :: str
+ if (first) then
+ first = .false.
+ if (allocated (str)) call abort ()
+ str = "ABCDEF"
+ end if
+ if (.not. allocated (str)) call abort ()
+ if (len (str) /= 6) call abort ()
+ if (str(1:6) /= "ABCDEF") call abort ()
+end subroutine bar
+
+! Deferred-length string array
+subroutine bar_array()
+ logical, save :: first = .true.
+ character(len=:), allocatable :: str
+ if (first) then
+ first = .false.
+ if (allocated (str)) call abort ()
+ str = "ABCDEF"
+ end if
+ if (.not. allocated (str)) call abort ()
+ if (len (str) /= 6) call abort ()
+ if (str(1:6) /= "ABCDEF") call abort ()
+end subroutine bar_array
+
+call foo(1)
+call foo(2)
+call bar()
+call bar_array()
+call bar()
+call bar_array()
+end