aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Schlüter <tobi@gcc.gnu.org>2004-07-09 16:53:45 +0200
committerTobias Schlüter <tobi@gcc.gnu.org>2004-07-09 16:53:45 +0200
commitd3fcc995c27e851a73a433b6ffd967563af080cd (patch)
treef2e67cc2562a5c7a5081a98c7b2a88756df9ea67
parent5b1c60e9de5246e484e15305795b8f9557ccefcd (diff)
downloadgcc-d3fcc995c27e851a73a433b6ffd967563af080cd.zip
gcc-d3fcc995c27e851a73a433b6ffd967563af080cd.tar.gz
gcc-d3fcc995c27e851a73a433b6ffd967563af080cd.tar.bz2
re PR fortran/15481 ([meta-bugs] frontend adds superfluous symbols to namespaces)
fortran/ 2004-07-09 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> PR fortran/15481 PR fortran/13372 PR fortran/13575 PR fortran/15978 * module.c (write_symbol, write_symtree): Remove workaround. * primary.c (match_actual_arglist): Enhance comment. (gfc_match_rvalue): Handle function call with first argument a keyword argument correctly. * resolve.c (resolve_symbol): Change call to gfc_set_default_type to issue error if no implicit type can be found. * trans-decl.c (gfc_create_module_variable): Remove workaround. testsuite/ PR fortran/15481 PR fortran/13372 PR fortran/13575 PR fortran/15978 * gfortran.fortran-torture/compile/implicit_2.f90: New test. Also fixed David Billinghursts ChangeLog entry to use GMT From-SVN: r84373
-rw-r--r--gcc/fortran/module.c13
-rw-r--r--gcc/fortran/primary.c58
-rw-r--r--gcc/fortran/resolve.c2
-rw-r--r--gcc/fortran/trans-decl.c6
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/gfortran.fortran-torture/compile/implicit_2.f906
6 files changed, 51 insertions, 44 deletions
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 7f720ba..9813b54 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -3189,13 +3189,6 @@ write_symbol (int n, gfc_symbol * sym)
if (sym->attr.flavor == FL_UNKNOWN || sym->attr.flavor == FL_LABEL)
gfc_internal_error ("write_symbol(): bad module symbol '%s'", sym->name);
-
- if (sym->attr.flavor == FL_VARIABLE && sym->ts.type == BT_UNKNOWN)
- /* TODO: this is a workaround for some of the problems in PR15481,
- and fixes the dependent bug PR13372. In an ideal frontend, this
- should never happen. */
- return;
-
mio_integer (&n);
mio_internal_string (sym->name);
@@ -3319,12 +3312,6 @@ write_symtree (gfc_symtree * st)
&& !sym->attr.subroutine && !sym->attr.function))
return;
- if (sym->attr.flavor == FL_VARIABLE && sym->ts.type == BT_UNKNOWN)
- /* TODO: this is a workaround for some of the problems in PR15481,
- and fixes the dependent bug PR13372. In an ideal frontend, this
- should never happen. */
- return;
-
if (check_unique_name (st->name))
return;
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index e1f4049..3593155 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -1400,7 +1400,8 @@ cleanup:
the opening parenthesis to the closing parenthesis. The argument
list is assumed to allow keyword arguments because we don't know if
the symbol associated with the procedure has an implicit interface
- or not. We make sure keywords are unique. */
+ or not. We make sure keywords are unique. If SUB_FLAG is set,
+ we're matching the argument list of a subroutine. */
match
gfc_match_actual_arglist (int sub_flag, gfc_actual_arglist ** argp)
@@ -1839,13 +1840,13 @@ match
gfc_match_rvalue (gfc_expr ** result)
{
gfc_actual_arglist *actual_arglist;
- char name[GFC_MAX_SYMBOL_LEN + 1];
+ char name[GFC_MAX_SYMBOL_LEN + 1], argname[GFC_MAX_SYMBOL_LEN + 1];
gfc_state_data *st;
gfc_symbol *sym;
gfc_symtree *symtree;
- locus where;
+ locus where, old_loc;
gfc_expr *e;
- match m;
+ match m, m2;
int i;
m = gfc_match_name (name);
@@ -2044,35 +2045,46 @@ gfc_match_rvalue (gfc_expr ** result)
break;
}
- /* See if this could possibly be a substring reference of a name
- that we're not sure is a variable yet. */
+ /* See if this is a function reference with a keyword argument
+ as first argument. We do this because otherwise a spurious
+ symbol would end up in the symbol table. */
+
+ old_loc = gfc_current_locus;
+ m2 = gfc_match (" ( %n =", argname);
+ gfc_current_locus = old_loc;
e = gfc_get_expr ();
e->symtree = symtree;
- if ((sym->ts.type == BT_UNKNOWN || sym->ts.type == BT_CHARACTER)
- && match_substring (sym->ts.cl, 0, &e->ref) == MATCH_YES)
+ if (m2 != MATCH_YES)
{
+ /* See if this could possibly be a substring reference of a name
+ that we're not sure is a variable yet. */
- e->expr_type = EXPR_VARIABLE;
-
- if (sym->attr.flavor != FL_VARIABLE
- && gfc_add_flavor (&sym->attr, FL_VARIABLE, NULL) == FAILURE)
+ if ((sym->ts.type == BT_UNKNOWN || sym->ts.type == BT_CHARACTER)
+ && match_substring (sym->ts.cl, 0, &e->ref) == MATCH_YES)
{
- m = MATCH_ERROR;
- break;
- }
- if (sym->ts.type == BT_UNKNOWN
- && gfc_set_default_type (sym, 1, NULL) == FAILURE)
- {
- m = MATCH_ERROR;
+ e->expr_type = EXPR_VARIABLE;
+
+ if (sym->attr.flavor != FL_VARIABLE
+ && gfc_add_flavor (&sym->attr, FL_VARIABLE, NULL) == FAILURE)
+ {
+ m = MATCH_ERROR;
+ break;
+ }
+
+ if (sym->ts.type == BT_UNKNOWN
+ && gfc_set_default_type (sym, 1, NULL) == FAILURE)
+ {
+ m = MATCH_ERROR;
+ break;
+ }
+
+ e->ts = sym->ts;
+ m = MATCH_YES;
break;
}
-
- e->ts = sym->ts;
- m = MATCH_YES;
- break;
}
/* Give up, assume we have a function. */
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 03851f5..a107095 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -3714,7 +3714,7 @@ resolve_symbol (gfc_symbol * sym)
if (sym->ts.type == BT_UNKNOWN)
{
if (sym->attr.flavor == FL_VARIABLE || sym->attr.flavor == FL_PARAMETER)
- gfc_set_default_type (sym, 0, NULL);
+ gfc_set_default_type (sym, 1, NULL);
if (sym->attr.flavor == FL_PROCEDURE && sym->attr.function)
{
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 47d9ba5..4cb2a65 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1798,12 +1798,6 @@ gfc_create_module_variable (gfc_symbol * sym)
&& (sym->attr.flavor != FL_PARAMETER || sym->attr.dimension == 0))
return;
- if (sym->attr.flavor == FL_VARIABLE && sym->ts.type == BT_UNKNOWN)
- /* TODO: This is a workaround for the issue outlined in PR 15481,
- and it fixes the bug in PR13372. This should never happen in an
- ideal frontend. */
- return;
-
/* Don't generate variables from other modules. */
if (sym->attr.use_assoc)
return;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 035b99c..dd99748 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,4 +1,12 @@
-2004-07-10 David Billinghurst (David.Billinghurst@riotinto.com)
+2004-07-09 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
+
+ PR fortran/15481
+ PR fortran/13372
+ PR fortran/13575
+ PR fortran/15978
+ * gfortran.fortran-torture/compile/implicit_2.f90: New test.
+
+2004-07-09 David Billinghurst (David.Billinghurst@riotinto.com)
* lib/gfortran-dg.exp (gfortran-dg-test): Adapt regular
expression to match gfortran warning/error messages
diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/implicit_2.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/implicit_2.f90
new file mode 100644
index 0000000..c5b8456
--- /dev/null
+++ b/gcc/testsuite/gfortran.fortran-torture/compile/implicit_2.f90
@@ -0,0 +1,6 @@
+! PR 13372 -- we incorrectly added a symbol for p, which broke implicit typing
+module t
+implicit none
+integer, parameter :: F = selected_real_kind(P = 6, R = 37)
+end module t
+