diff options
author | Francois-Xavier Coudert <coudert@clipper.ens.fr> | 2006-11-17 12:11:25 +0100 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2006-11-17 11:11:25 +0000 |
commit | 31198773e456d1a8ecabdd576fa3a9d4412cbf07 (patch) | |
tree | 2eedcb4f55a3cf78d29fa8c589d673751e940362 /gcc/fortran/module.c | |
parent | 9bd6112c5a2585eb58564f583ad84da87fe27d3a (diff) | |
download | gcc-31198773e456d1a8ecabdd576fa3a9d4412cbf07.zip gcc-31198773e456d1a8ecabdd576fa3a9d4412cbf07.tar.gz gcc-31198773e456d1a8ecabdd576fa3a9d4412cbf07.tar.bz2 |
gfortran.h (gfc_add_intrinsic_modules_path, [...]): New prototypes.
* gfortran.h (gfc_add_intrinsic_modules_path,
gfc_open_intrinsic_module): New prototypes.
(gfc_add_include_path, gfc_open_included_file): Update prototypes.
* lang.opt: Add -fintrinsic-modules-path option.
* module.c (gfc_match_use): Match the Fortran 2003 form of
USE statement.
(gfc_use_module): Also handle intrinsic modules.
* scanner.c (gfc_directorylist): Add use_for_modules for field.
(intrinsic_modules_dirs): New static variable.
(add_path_to_list, gfc_add_intrinsic_modules_path): New functions.
(gfc_add_include_path): Use the new add_path_to_list helper
function.
(gfc_release_include_path): Free memory for intrinsic_modules_dirs.
(open_included_file, gfc_open_intrinsic_module): New functions.
(gfc_open_included_file): Use the new open_included_file
helper function.
* lang-specs.h: Use the new -fintrinsic-modules-path option.
* parse.c (decode_statement): Do not match the required space
after USE here.
* options.c (gfc_handle_option): Handle the new option. Use new
prototype for gfc_add_include_path.
(gfc_post_options): Use new prototype for gfc_add_include_path.
* gfortran.dg/use_1.f90: New test.
* gfortran.dg/use_1.f90: New test.
* gfortran.dg/use_1.f90: New test.
From-SVN: r118930
Diffstat (limited to 'gcc/fortran/module.c')
-rw-r--r-- | gcc/fortran/module.c | 86 |
1 files changed, 84 insertions, 2 deletions
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index f7b45f3..dd103b8 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -173,6 +173,9 @@ static FILE *module_fp; /* The name of the module we're reading (USE'ing) or writing. */ static char module_name[GFC_MAX_SYMBOL_LEN + 1]; +/* The way the module we're reading was specified. */ +static bool specified_nonint, specified_int; + static int module_line, module_column, only_flag; static enum { IO_INPUT, IO_OUTPUT } @@ -483,12 +486,65 @@ free_rename (void) match gfc_match_use (void) { - char name[GFC_MAX_SYMBOL_LEN + 1]; + char name[GFC_MAX_SYMBOL_LEN + 1], module_nature[GFC_MAX_SYMBOL_LEN + 1]; gfc_use_rename *tail = NULL, *new; interface_type type; gfc_intrinsic_op operator; match m; + specified_int = false; + specified_nonint = false; + + if (gfc_match (" , ") == MATCH_YES) + { + if ((m = gfc_match (" %n ::", module_nature)) == MATCH_YES) + { + if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: module " + "nature in USE statement at %C") == FAILURE) + return MATCH_ERROR; + + if (strcmp (module_nature, "intrinsic") == 0) + specified_int = true; + else + { + if (strcmp (module_nature, "non_intrinsic") == 0) + specified_nonint = true; + else + { + gfc_error ("Module nature in USE statement at %C shall " + "be either INTRINSIC or NON_INTRINSIC"); + return MATCH_ERROR; + } + } + } + else + { + /* Help output a better error message than "Unclassifiable + statement". */ + gfc_match (" %n", module_nature); + if (strcmp (module_nature, "intrinsic") == 0 + || strcmp (module_nature, "non_intrinsic") == 0) + gfc_error ("\"::\" was expected after module nature at %C " + "but was not found"); + return m; + } + } + else + { + m = gfc_match (" ::"); + if (m == MATCH_YES && + gfc_notify_std (GFC_STD_F2003, "Fortran 2003: " + "\"USE :: module\" at %C") == FAILURE) + return MATCH_ERROR; + + if (m != MATCH_YES) + { + m = gfc_match ("% "); + if (m != MATCH_YES) + return m; + } + } + m = gfc_match_name (module_name); if (m != MATCH_YES) return m; @@ -3801,7 +3857,33 @@ gfc_use_module (void) strcpy (filename, module_name); strcat (filename, MODULE_EXTENSION); - module_fp = gfc_open_included_file (filename, true); + /* First, try to find an non-intrinsic module, unless the USE statement + specified that the module is intrinsic. */ + module_fp = NULL; + if (!specified_int) + module_fp = gfc_open_included_file (filename, true, true); + + /* Then, see if it's an intrinsic one, unless the USE statement + specified that the module is non-intrinsic. */ + if (module_fp == NULL && !specified_nonint) + { +#if 0 + if (strcmp (module_name, "iso_fortran_env") == 0 + && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: " + "ISO_FORTRAN_ENV intrinsic module at %C") != FAILURE) + { + use_iso_fortran_env_module (); + return; + } +#endif + + module_fp = gfc_open_intrinsic_module (filename); + + if (module_fp == NULL && specified_int) + gfc_fatal_error ("Can't find an intrinsic module named '%s' at %C", + module_name); + } + if (module_fp == NULL) gfc_fatal_error ("Can't open module file '%s' for reading at %C: %s", filename, strerror (errno)); |