diff options
| author | Tobias Burnus <burnus@net-b.de> | 2006-11-15 16:46:42 +0100 |
|---|---|---|
| committer | Tobias Burnus <burnus@gcc.gnu.org> | 2006-11-15 16:46:42 +0100 |
| commit | 8998be203171c0f305386fa12306aa282ddb5d06 (patch) | |
| tree | 72938501a423f4774c1cefa48f17941af90b4ee7 /gcc/fortran/decl.c | |
| parent | dd5f63f83e862faee09a5a02bd417438a81ef8a1 (diff) | |
| download | gcc-8998be203171c0f305386fa12306aa282ddb5d06.zip gcc-8998be203171c0f305386fa12306aa282ddb5d06.tar.gz gcc-8998be203171c0f305386fa12306aa282ddb5d06.tar.bz2 | |
re PR fortran/27546 (IMPORT is broken)
fortran/
2006-11-15 Tobias Burnus <burnus@net-b.de>
PR fortran/27546
* decl.c (gfc_match_import,variable_decl):
Add IMPORT support.
(gfc_match_kind_spec): Fix typo in gfc_error.
* gfortran.h (gfc_namespace, gfc_statement):
Add IMPORT support.
* parse.c (decode_statement,gfc_ascii_statement,
verify_st_order): Add IMPORT support.
* match.h: Add gfc_match_import.
* gfortran.texi: Add IMPORT to the supported
Fortran 2003 features.
testsuite/
2006-11-15 Tobias Burnus <burnus@net-b.de>
PR fortran/27546
* gfortran.dg/import.f90: New test.
* gfortran.dg/import2.f90: New test.
* gfortran.dg/import3.f90: New test.
From-SVN: r118857
Diffstat (limited to 'gcc/fortran/decl.c')
| -rw-r--r-- | gcc/fortran/decl.c | 95 |
1 files changed, 93 insertions, 2 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 6c5cfcc..ae4271c 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1220,7 +1220,8 @@ variable_decl (int elem) if (current_ts.type == BT_DERIVED && gfc_current_ns->proc_name && gfc_current_ns->proc_name->attr.if_source == IFSRC_IFBODY - && current_ts.derived->ns != gfc_current_ns) + && current_ts.derived->ns != gfc_current_ns + && !gfc_current_ns->has_import_set) { gfc_error ("the type of '%s' at %C has not been declared within the " "interface", name); @@ -1483,7 +1484,7 @@ gfc_match_kind_spec (gfc_typespec * ts) if (gfc_match_char (')') != MATCH_YES) { - gfc_error ("Missing right paren at %C"); + gfc_error ("Missing right parenthesis at %C"); goto no_match; } @@ -2005,6 +2006,96 @@ error: return MATCH_ERROR; } +match +gfc_match_import (void) +{ + char name[GFC_MAX_SYMBOL_LEN + 1]; + match m; + gfc_symbol *sym; + gfc_symtree *st; + + if (gfc_current_ns->proc_name == NULL || + gfc_current_ns->proc_name->attr.if_source != IFSRC_IFBODY) + { + gfc_error ("IMPORT statement at %C only permitted in " + "an INTERFACE body"); + return MATCH_ERROR; + } + + if (gfc_notify_std (GFC_STD_F2003, + "Fortran 2003: IMPORT statement at %C") + == FAILURE) + return MATCH_ERROR; + + if (gfc_match_eos () == MATCH_YES) + { + /* All host variables should be imported. */ + gfc_current_ns->has_import_set = 1; + return MATCH_YES; + } + + if (gfc_match (" ::") == MATCH_YES) + { + if (gfc_match_eos () == MATCH_YES) + { + gfc_error ("Expecting list of named entities at %C"); + return MATCH_ERROR; + } + } + + for(;;) + { + m = gfc_match (" %n", name); + switch (m) + { + case MATCH_YES: + if (gfc_find_symbol (name, gfc_current_ns->parent, 1, &sym)) + { + gfc_error ("Type name '%s' at %C is ambiguous", name); + return MATCH_ERROR; + } + + if (sym == NULL) + { + gfc_error ("Cannot IMPORT '%s' from host scoping unit " + "at %C - does not exist.", name); + return MATCH_ERROR; + } + + if (gfc_find_symtree (gfc_current_ns->sym_root,name)) + { + gfc_warning ("'%s' is already IMPORTed from host scoping unit " + "at %C.", name); + goto next_item; + } + + st = gfc_new_symtree (&gfc_current_ns->sym_root, name); + st->n.sym = sym; + sym->refs++; + sym->ns = gfc_current_ns; + + goto next_item; + + case MATCH_NO: + break; + + case MATCH_ERROR: + return MATCH_ERROR; + } + + next_item: + if (gfc_match_eos () == MATCH_YES) + break; + if (gfc_match_char (',') != MATCH_YES) + goto syntax; + } + + return MATCH_YES; + +syntax: + gfc_error ("Syntax error in IMPORT statement at %C"); + return MATCH_ERROR; +} /* Matches an attribute specification including array specs. If successful, leaves the variables current_attr and current_as |
