This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
PATCH: fortran/26041: FORTRAN compiler won't compile the valid code
- From: "H. J. Lu" <hjl at lucon dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: fortran at gcc dot gnu dot org
- Date: Tue, 31 Jan 2006 15:52:12 -0800
- Subject: PATCH: fortran/26041: FORTRAN compiler won't compile the valid code
The problem is in gfc_resolve:
void
gfc_resolve (gfc_namespace * ns)
{
...
gfc_traverse_ns (ns, resolve_symbol);
...
for (n = ns->contained; n; n = n->sibling)
gfc_resolve (ns)
...
resolve_code (ns->code, ns);
...
}
Depending on the order of the code, resolve_code may be called before
symbols are resolved. This patch tries to resolve symbols before
calling resolve_code. Tested on Linux/i686.
H.J.
---
2006-01-31 H.J. Lu <hongjiu.lu@intel.com>
PR fortran/26041
* resolve.c (gfc_resolve_type): New function.
(gfc_resolve): Use it.
--- gcc/fortran/resolve.c.type 2006-01-27 14:24:40.000000000 -0800
+++ gcc/fortran/resolve.c 2006-01-31 15:42:07.000000000 -0800
@@ -5771,21 +5771,14 @@ resolve_fntype (gfc_namespace * ns)
}
-/* This function is called after a complete program unit has been compiled.
- Its purpose is to examine all of the expressions associated with a program
- unit, assign types to all intermediate expressions, make sure that all
- assignments are to compatible types and figure out which names refer to
- which functions or subroutines. */
-
-void
-gfc_resolve (gfc_namespace * ns)
+static void
+gfc_resolve_type (gfc_namespace * ns)
{
- gfc_namespace *old_ns, *n;
+ gfc_namespace *n;
gfc_charlen *cl;
gfc_data *d;
gfc_equiv *eq;
- old_ns = gfc_current_ns;
gfc_current_ns = ns;
resolve_entries (ns);
@@ -5803,7 +5796,7 @@ gfc_resolve (gfc_namespace * ns)
"also be PURE", n->proc_name->name,
&n->proc_name->declared_at);
- gfc_resolve (n);
+ gfc_resolve_type (n);
}
forall_flag = 0;
@@ -5827,12 +5820,37 @@ gfc_resolve (gfc_namespace * ns)
for (eq = ns->equiv; eq; eq = eq->next)
resolve_equivalence (eq);
- cs_base = NULL;
- resolve_code (ns->code, ns);
-
/* Warn about unused labels. */
if (gfc_option.warn_unused_labels)
warn_unused_label (ns->st_labels);
+}
+
+
+/* This function is called after a complete program unit has been compiled.
+ Its purpose is to examine all of the expressions associated with a program
+ unit, assign types to all intermediate expressions, make sure that all
+ assignments are to compatible types and figure out which names refer to
+ which functions or subroutines. */
+
+void
+gfc_resolve (gfc_namespace * ns)
+{
+ gfc_namespace *old_ns, *n;
+
+ old_ns = gfc_current_ns;
+
+ gfc_resolve_type (ns);
+
+ for (n = ns->contained; n; n = n->sibling)
+ {
+ gfc_current_ns = n;
+ cs_base = NULL;
+ resolve_code (n->code, n);
+ }
+
+ gfc_current_ns = ns;
+ cs_base = NULL;
+ resolve_code (ns->code, ns);
gfc_current_ns = old_ns;
}