diff options
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 173ad45..09ded01 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -301,6 +301,7 @@ match_data_constant (gfc_expr **result) gfc_symbol *sym; gfc_expr *expr; match m; + locus old_loc; m = gfc_match_literal_constant (&expr, 1); if (m == MATCH_YES) @@ -316,6 +317,23 @@ match_data_constant (gfc_expr **result) if (m != MATCH_NO) return m; + old_loc = gfc_current_locus; + + /* Should this be a structure component, try to match it + before matching a name. */ + m = gfc_match_rvalue (result); + if (m == MATCH_ERROR) + return m; + + if (m == MATCH_YES && (*result)->expr_type == EXPR_STRUCTURE) + { + if (gfc_simplify_expr (*result, 0) == FAILURE) + m = MATCH_ERROR; + return m; + } + + gfc_current_locus = old_loc; + m = gfc_match_name (name); if (m != MATCH_YES) return m; @@ -2041,7 +2059,17 @@ gfc_match_import (void) switch (m) { case MATCH_YES: - if (gfc_find_symbol (name, gfc_current_ns->parent, 1, &sym)) + if (gfc_current_ns->parent != NULL + && gfc_find_symbol (name, gfc_current_ns->parent, + 1, &sym)) + { + gfc_error ("Type name '%s' at %C is ambiguous", name); + return MATCH_ERROR; + } + else if (gfc_current_ns->proc_name->ns->parent != NULL + && gfc_find_symbol (name, + gfc_current_ns->proc_name->ns->parent, + 1, &sym)) { gfc_error ("Type name '%s' at %C is ambiguous", name); return MATCH_ERROR; |