[Patch, fortran] PR19292 - g77 features missing or broken: PR18737 and PR21565

Paul Thomas paulthomas2@wanadoo.fr
Wed Oct 26 13:42:00 GMT 2005


:ADDPATCH fortran:

This is my first contribution to clearing up the broken or missing g77 
features.

Please find a patch to symbol.c that fixes two of the entries in the g77 
meta-bug, PR19292.  Both are very simple and, since they both modify the 
same file, have been submitted together.

1] PR18737: If, after the call to gfc_get_default_type, an external 
symbol still does not have a type, we have an error.
2] PR21565: Add to check_conflict the constraint that a namelist object 
cannot be in block data.

Testcases are provided for both.

Bootstrapped and regtested on FC3/Athlon.  OK for mainline and 4.0?

Paul T

2005-10-26  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/21565
    PR fortran/18737
    * symbol.c (gfc_set_default_type): Generate an error if an
    the type of an external symbol has not now been resolved.
    (check_conflict): An object cannot be in a namelist and in
    block data.

2005-10-26  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/21565
    gfortran.dg/namelist_blockdata.f90: New test.

    PR fortran/18737
    gfortran.dg/external_implicit_none.f90: New test.


Index: gcc/gcc/fortran/symbol.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/symbol.c,v
retrieving revision 1.40
diff -c -p -r1.40 symbol.c
*** gcc/gcc/fortran/symbol.c    25 Oct 2005 18:43:21 -0000    1.40
--- gcc/gcc/fortran/symbol.c    26 Oct 2005 13:15:59 -0000
*************** gfc_set_default_type (gfc_symbol * sym,
*** 234,239 ****
--- 234,243 ----
        sym->attr.untyped = 1; /* Ensure we only give an error once.  */
      }
 
+       if (sym->attr.external)
+     gfc_error ("External symbol '%s' at %L is of unknown type",
+            sym->name, &sym->declared_at);
+
        return FAILURE;
      }
 
*************** check_conflict (symbol_attribute * attr,
*** 283,288 ****
--- 287,294 ----
      {
        a1 = NULL;
 
+       if (attr->in_namelist)
+     a1 = in_namelist;
        if (attr->allocatable)
      a1 = allocatable;
        if (attr->external)

=======================namelist_blockdata.f=========================

! { dg-do compile }
! Tests fix for PR21565 - object cannot be in namelist and block data.
      block data
      common /foo/ a
      namelist /foo_n/ a ! { dg-error "not allowed in BLOCK DATA" }
      data a /1.0/
      end

=================external_implicit_none.f90=========================

! { dg-do compile }
! Tests fix for PR18737 - ICE on external symbol of unknown type.
program test
  implicit none
  real(8) :: x
  external bug  ! { dg-error "is of unknown type" }

  x = 2
  print *, bug(x)
 
end program test






More information about the Fortran mailing list