This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] PR 47569 - fix ICE (regression) and fix diagnostic


On Sunday 13 February 2011 13:30:39 Tobias Burnus wrote:
> Dear Mikael, dear all,
> 
> attached is an updated version of the patch, incorporating the
> suggestions of Mikael (thanks!). I think I have indeed misread part of
> the standard. (Twice!)
> 
> The new patch continues to accepts all default/C_CHAR kind characters.
> Other character kinds are still accepted, but now properly diagnosed.
> The pointer checking and the handling of (nested) components has been
> fixed - which was the original PR.
> 
> Build and regtested on x86-64-linux
> OK for the trunk? To which of 4.3/4.4/4.5 do we want to backport it?
> 
> Tobias
> 
> 
> arg-check-ice-v5.diff
>   2011-02-13  Tobias Burnus  <burnus@net-b.de>
> 
>         PR fortran/47569
>         * interface.c (compare_parameter): Avoid ICE with
>         character components.
> 
> 2011-02-13  Tobias Burnus  <burnus@net-b.de>
> 
>         * gfortran.dg/argument_checking_13.f90: Update dg-error.
>         * gfortran.dg/argument_checking_17.f90: New.
> 
> --- /dev/null   2011-02-12 08:11:41.879999996 +0100
> +++ gcc/gcc/testsuite/gfortran.dg/argument_checking_17.f90      2011-02-01 
15:02:42.000000000 +0100
> @@ -0,0 +1,26 @@
> +! { dg-do compile }
> +!
> +! PR fortran/47569
> +!
> +! Contributed by Jos de Kloe 
> +!
> +module teststr
> +  implicit none
> +  integer, parameter :: GRH_SIZE = 20, NMAX = 41624
> +  type strtype
> +    integer   :: size
> +    character :: mdr(NMAX)
> +  end type strtype
> +contains
> +  subroutine sub2(string,str_size)
> +    integer,intent(in)    :: str_size
> +    character,intent(out) :: string(str_size)
> +    string(:) = 'a'
> +  end subroutine sub2
> +  subroutine sub1(a)
> +    type(strtype),intent(inout) :: a
> +    call sub2(a%mdr(GRH_SIZE+1),a%size-GRH_SIZE)
> +  end subroutine sub1
> +end module teststr
> +
> +! { dg-final { cleanup-modules "teststr" } }
> diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
> index 1e5df61..120f0ce 100644
> --- a/gcc/fortran/interface.c
> +++ b/gcc/fortran/interface.c
> @@ -1461,7 +1461,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr 
*actual,
>                    int ranks_must_agree, int is_elemental, locus *where)
>  {
>    gfc_ref *ref;
> -  bool rank_check;
> +  bool rank_check, is_pointer;
>  
>    /* If the formal arg has type BT_VOID, it's to one of the iso_c_binding
>       procs c_f_pointer or c_f_procpointer, and we need to accept most
> @@ -1672,23 +1672,56 @@ compare_parameter (gfc_symbol *formal, gfc_expr 
*actual,
>      return 1;
>  
>    /* At this point, we are considering a scalar passed to an array.   This
> -     is valid (cf. F95 12.4.1.1; F2003 12.4.1.2),
> +     is valid (cf. F95 12.4.1.1, F2003 12.4.1.2, and F2008 12.5.2.4),
>       - if the actual argument is (a substring of) an element of a
> -       non-assumed-shape/non-pointer array;
> -     - (F2003) if the actual argument is of type character.  */
> +       non-assumed-shape/non-pointer/non-polymorphic array;
> +     - (F2003) if the actual argument is of type character of 
default/c_char
> +       kind.  */
One could emphasize here that it is a or, i.e. only one condition has to be 
met. 
Maybe it is the reason why you misread the standard?

Anyway, the patch is OK; about the backport:
4.5: yes, 4.3: no need to bother (unless you feel like bothering...)
4.4: as you wish; the bug reporter would probably appreciate to have it in 
4.4.

Thanks
Mikael



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]