aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/resolve.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r--gcc/fortran/resolve.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 41e13b0..84d42ee 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -1487,6 +1487,8 @@ pure_function (gfc_expr *e, const char **name)
{
int pure;
+ *name = NULL;
+
if (e->symtree != NULL
&& e->symtree->n.sym != NULL
&& e->symtree->n.sym->attr.proc == PROC_ST_FUNCTION)
@@ -1663,6 +1665,7 @@ resolve_function (gfc_expr *expr)
#undef GENERIC_ID
need_full_assumed_size = temp;
+ name = NULL;
if (!pure_function (expr, &name) && name)
{
@@ -5534,7 +5537,7 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
int flag;
int i;
gfc_expr *e;
- gfc_expr *constructor_expr;
+ gfc_component *c;
const char *auto_save_msg;
auto_save_msg = "automatic object '%s' at %L cannot have the "
@@ -5668,18 +5671,21 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
}
}
+ /* Do not use gfc_default_initializer to test for a default initializer
+ in the fortran because it generates a hidden default for allocatable
+ components. */
+ c = NULL;
+ if (sym->ts.type == BT_DERIVED && !(sym->value || flag))
+ for (c = sym->ts.derived->components; c; c = c->next)
+ if (c->initializer)
+ break;
+
/* 4th constraint in section 11.3: "If an object of a type for which
component-initialization is specified (R429) appears in the
specification-part of a module and does not have the ALLOCATABLE
or POINTER attribute, the object shall have the SAVE attribute." */
-
- constructor_expr = NULL;
- if (sym->ts.type == BT_DERIVED && !(sym->value || flag))
- constructor_expr = gfc_default_initializer (&sym->ts);
-
- if (sym->ns->proc_name
+ if (c && sym->ns->proc_name
&& sym->ns->proc_name->attr.flavor == FL_MODULE
- && constructor_expr
&& !sym->ns->save_all && !sym->attr.save
&& !sym->attr.pointer && !sym->attr.allocatable)
{