diff options
author | Francois-Xavier Coudert <coudert@clipper.ens.fr> | 2007-01-21 15:32:53 +0000 |
---|---|---|
committer | Francois-Xavier Coudert <coudert@clipper.ens.fr> | 2007-01-21 15:32:53 +0000 |
commit | 7dc4229efcbd8a18464044aaeac18e977a3ededb (patch) | |
tree | 7b362ea16082f4e114094469d5d772e6b579af31 | |
parent | 338e58450403176840f7c2ef6552027a78b301c4 (diff) |
* gfortran.h: Add new fields from_intmod and intmod_sym_id to the
gfc_symbol structure, to keep track of symbols coming from
intrinsic modules so we can special-case them when needed.
* symbol.c (generate_isocbinding_symbol): Set these new fields.
* module.c: Set these new fields, and use the fact that we know
have a symbolic id per symbol to rework the code dealing with
ISO_FORTRAN_ENV.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/fortran-experiments@121028 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/fortran/ChangeLog.isocbinding | 12 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 32 | ||||
-rw-r--r-- | gcc/fortran/module.c | 51 | ||||
-rw-r--r-- | gcc/fortran/symbol.c | 2 |
4 files changed, 80 insertions, 17 deletions
diff --git a/gcc/fortran/ChangeLog.isocbinding b/gcc/fortran/ChangeLog.isocbinding index 9f83961816a..26184e67df9 100644 --- a/gcc/fortran/ChangeLog.isocbinding +++ b/gcc/fortran/ChangeLog.isocbinding @@ -3,7 +3,19 @@ Welcome to the ISO_C_BINDING sandbox! Please comment here the changes you make to the code, dated with every commit to the branch, so that we don't get lost. + +2007-01-21 Francois-Xavier Coudert <coudert@clipper.ens.fr> + + * gfortran.h: Add new fields from_intmod and intmod_sym_id to the + gfc_symbol structure, to keep track of symbols coming from + intrinsic modules so we can special-case them when needed. + * symbol.c (generate_isocbinding_symbol): Set these new fields. + * module.c: Set these new fields, and use the fact that we know + have a symbolic id per symbol to rework the code dealing with + ISO_FORTRAN_ENV. + 2007-01-19 Christopher D. Rickett + * decl.c: Fixed bugs in verifying BIND(C) variables and C interoperable kinds. Modified the way errors for each are handled in some cases. diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 159c35c6238..d81b0df3ebe 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -483,6 +483,16 @@ typedef enum gfc_generic_isym_id gfc_generic_isym_id; #define BBT_HEADER(self) int priority; struct self *left, *right #define NAMED_INTCST(a,b,c) a, +typedef enum +{ + ISOFORTRANENV_INVALID = -1, +#include "iso-fortran-env.def" + ISOFORTRANENV_LAST, ISOFORTRANENV_NUMBER = ISOFORTRANENV_LAST +} +iso_fortran_env_symbol; +#undef NAMED_INTCST + +#define NAMED_INTCST(a,b,c) a, #define NAMED_REALCST(a,b,c) a, #define NAMED_CMPXCST(a,b,c) a, #define NAMED_LOGCST(a,b,c) a, @@ -498,6 +508,20 @@ typedef enum ISOCBINDING_NUMBER = ISOCBINDING_LAST } iso_c_binding_symbol; +#undef NAMED_INTCST +#undef NAMED_REALCST +#undef NAMED_CMPXCST +#undef NAMED_LOGCST +#undef NAMED_CHARKNDCST +#undef NAMED_CHARCST +#undef DERIVED_TYPE +#undef PROCEDURE + +typedef enum +{ + INTMOD_NONE = 0, INTMOD_ISO_FORTRAN_ENV, INTMOD_ISO_C_BINDING +} +intmod_id; typedef struct { @@ -934,6 +958,14 @@ typedef struct gfc_symbol tree backend_decl; + /* Identity of the intrinsic module the symbol comes from, or + INTMOD_NONE if it's not imported from a intrinsic module. */ + intmod_id from_intmod; + /* Identity of the symbol from intrinsic modules, from enums maintained + separately by each intrinsic module. Used together with from_intmod, + it uniquely identifies a symbol from an intrinsic module. */ + int intmod_sym_id; + /* this may be repetitive, since the typespec now has a binding * label field. --Rickett, 10.17.05 */ diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index eb6f0b734a7..a837b968e57 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -85,6 +85,15 @@ typedef struct } module_locus; +/* Structure for list of symbols of intrinsic modules. */ +typedef struct +{ + int id; + const char *name; + int value; +} +intmod_sym; + typedef enum { @@ -3988,7 +3997,9 @@ import_iso_c_binding_module (void) "create symbol for %s", iso_c_module_name); mod_sym->attr.flavor = FL_MODULE; - mod_sym->module = gfc_get_string(iso_c_module_name); + mod_sym->attr.intrinsic = 1; + mod_sym->module = gfc_get_string (iso_c_module_name); + mod_sym->from_intmod = INTMOD_ISO_C_BINDING; } /* Generate the symbols for the named constants representing @@ -4039,7 +4050,8 @@ import_iso_c_binding_module (void) /* Add an integer named constant from a given module. */ static void -create_int_parameter (const char *name, int value, const char *modname) +create_int_parameter (const char *name, int value, const char *modname, + intmod_id module, int id) { gfc_symtree * tmp_symtree; gfc_symbol * sym; @@ -4062,6 +4074,8 @@ create_int_parameter (const char *name, int value, const char *modname) sym->ts.kind = gfc_default_integer_kind; sym->value = gfc_int_expr (value); sym->attr.use_assoc = 1; + sym->from_intmod = module; + sym->intmod_sym_id = id; } /* USE the ISO_FORTRAN_ENV intrinsic module. */ @@ -4075,14 +4089,14 @@ use_iso_fortran_env_module (void) gfc_symtree *mod_symtree; int i; - mstring symbol[] = { -#define NAMED_INTCST(a,b,c) minit(b,0), + intmod_sym symbol[] = { +#define NAMED_INTCST(a,b,c) { a, b, 0 }, #include "iso-fortran-env.def" #undef NAMED_INTCST - minit (NULL, -1234) }; + { ISOFORTRANENV_INVALID, NULL, -1234 } }; i = 0; -#define NAMED_INTCST(a,b,c) symbol[i++].tag = c; +#define NAMED_INTCST(a,b,c) symbol[i++].value = c; #include "iso-fortran-env.def" #undef NAMED_INTCST @@ -4097,6 +4111,7 @@ use_iso_fortran_env_module (void) mod_sym->attr.flavor = FL_MODULE; mod_sym->attr.intrinsic = 1; mod_sym->module = gfc_get_string (mod); + mod_sym->from_intmod = INTMOD_ISO_FORTRAN_ENV; } else if (!mod_symtree->n.sym->attr.intrinsic) @@ -4107,11 +4122,11 @@ use_iso_fortran_env_module (void) if (only_flag) for (u = gfc_rename_list; u; u = u->next) { - for (i = 0; symbol[i].string; i++) - if (strcmp (symbol[i].string, u->use_name) == 0) + for (i = 0; symbol[i].name; i++) + if (strcmp (symbol[i].name, u->use_name) == 0) break; - if (symbol[i].string == NULL) + if (symbol[i].name == NULL) { gfc_error ("Symbol '%s' referenced at %L does not exist in " "intrinsic module ISO_FORTRAN_ENV", u->use_name, @@ -4120,7 +4135,7 @@ use_iso_fortran_env_module (void) } if ((gfc_option.flag_default_integer || gfc_option.flag_default_real) - && strcmp (symbol[i].string, "numeric_storage_size") == 0) + && symbol[i].id == ISOFORTRANENV_NUMERIC_STORAGE_SIZE) gfc_warning_now ("Use of the NUMERIC_STORAGE_SIZE named constant " "from intrinsic module ISO_FORTRAN_ENV at %L is " "incompatible with option %s", &u->where, @@ -4128,17 +4143,18 @@ use_iso_fortran_env_module (void) ? "-fdefault-integer-8" : "-fdefault-real-8"); create_int_parameter (u->local_name[0] ? u->local_name - : symbol[i].string, - symbol[i].tag, mod); + : symbol[i].name, + symbol[i].value, mod, INTMOD_ISO_FORTRAN_ENV, + symbol[i].id); } else { - for (i = 0; symbol[i].string; i++) + for (i = 0; symbol[i].name; i++) { local_name = NULL; for (u = gfc_rename_list; u; u = u->next) { - if (strcmp (symbol[i].string, u->use_name) == 0) + if (strcmp (symbol[i].name, u->use_name) == 0) { local_name = u->local_name; u->found = 1; @@ -4147,15 +4163,16 @@ use_iso_fortran_env_module (void) } if ((gfc_option.flag_default_integer || gfc_option.flag_default_real) - && strcmp (symbol[i].string, "numeric_storage_size") == 0) + && symbol[i].id == ISOFORTRANENV_NUMERIC_STORAGE_SIZE) gfc_warning_now ("Use of the NUMERIC_STORAGE_SIZE named constant " "from intrinsic module ISO_FORTRAN_ENV at %C is " "incompatible with option %s", gfc_option.flag_default_integer ? "-fdefault-integer-8" : "-fdefault-real-8"); - create_int_parameter (local_name ? local_name : symbol[i].string, - symbol[i].tag, mod); + create_int_parameter (local_name ? local_name : symbol[i].name, + symbol[i].value, mod, INTMOD_ISO_FORTRAN_ENV, + symbol[i].id); } for (u = gfc_rename_list; u; u = u->next) diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index d0615cc5a0d..d1d4da2d51f 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -4002,6 +4002,8 @@ generate_isocbinding_symbol (const char * mod_name, iso_c_binding_symbol s, /* say what module this symbol belongs to */ tmp_sym->module = gfc_get_string (mod_name); + tmp_sym->from_intmod = INTMOD_ISO_C_BINDING; + tmp_sym->intmod_sym_id = s; switch (s) { |