------- Comment #5 from paul dot richard dot thomas at cea dot fr  2006-09-14 
15:23 -------
> module m
>   public function
>   interface function
>      module procedure foo4
>   end interface
> contains
>   subroutine foo4
>   end subroutine foo4
>   function foo5
>     foo5 = 0
>   end function foo5
> end module

If function foo5 is declared with a formal arglist or with empty brackets, this
example compiles correctly. The matcher is certainly behaving oddly!

This cures the original problem and does not seem to cause any regressions up
to "contained_1.f90" (I ran out of time this afternoon!).

Index: gcc/fortran/parse.c
===================================================================
*** gcc/fortran/parse.c (révision 116697)
--- gcc/fortran/parse.c (copie de travail)
*************** decode_statement (void)
*** 110,115 ****
--- 110,120 ----
        input "REALFUNCTIONA(N)" can mean several things in different
        contexts, so it (and its relatives) get special treatment.  */

+   if (gfc_match_end (&st) == MATCH_YES)
+     return st;
+   gfc_undo_symbols ();
+   gfc_current_locus = old_locus;
+
    if (gfc_current_state () == COMP_NONE
        || gfc_current_state () == COMP_INTERFACE
        || gfc_current_state () == COMP_CONTAINS)
*************** decode_statement (void)
*** 208,215 ****
        match ("else if", gfc_match_elseif, ST_ELSEIF);
        match ("enum , bind ( c )", gfc_match_enum, ST_ENUM);

-       if (gfc_match_end (&st) == MATCH_YES)
-       return st;

        match ("entry% ", gfc_match_entry, ST_ENTRY);
        match ("equivalence", gfc_match_equivalence, ST_EQUIVALENCE);
--- 213,218 ----
*************** parse_derived (void)
*** 1499,1504 ****
--- 1502,1509 ----
    int compiling_type, seen_private, seen_sequence, seen_component,
error_flag;

    gfc_statement st;
    gfc_state_data s;
+   gfc_symbol *sym;
+   gfc_component *c;

    error_flag = 0;

The matching of END can be moved after the next if block but no more.  One or
more of the matchers are not cleaning up after figuring "END" to be a variable
(a LHS?) and trying a match to an assignment or data statement.

Paul


-- 


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

Reply via email to