------- Comment #5 from sven dot buijssen at math dot uni-dortmund dot de  
2006-02-01 20:01 -------
I'm sorry. I had been experimenting which circumstances trigger the ice and
accidentally deleted the "optional" argument. To be valid the code needs to be
like

% cat > ice.f90 <<EOF
module ice
  implicit none
  contains

    subroutine foo()
    contains

      subroutine bar(baz)
        integer, optional :: baz
        if (present(baz)) then
        endif
      end subroutine bar
    end subroutine foo
end module
EOF

Just to be clear: gfortran revision 110475 does not complain about this
testcase. Only when I followed the advise of Andrew and integrated the patch
you suggested yesterday, H.J., then gfortran gives an ice.

% svn update -r HEAD
At revision 110475.
% svn diff
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c       (revision 110475)
+++ gcc/fortran/resolve.c       (working copy)
@@ -5771,21 +5771,14 @@
 }


-/* 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 @@
                   "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 @@
   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;
 }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26064

Reply via email to