[Patch, Fortran] PR55763 - reject MOLD with NULL() in init-data expressions
Mikael Morin
mikael.morin@sfr.fr
Fri Jan 4 11:28:00 GMT 2013
Hello,
Le 04/01/2013 00:23, Tobias Burnus a écrit :
> NULL with MOLD should be rejected as (default) initialization
> expression. From F2008:
>
> R506 null-init is function-reference
> C512 (R506) The function-reference shall be a reference to the intrinsic
> function NULL with no arguments.
>
> "null-init" occurs twice, as "R505 initialization" in "R505
> initialization" and in "R442 component-initialization" (default
> initialization).
>
>
> Before,
> integer, pointer :: p => null(x)
> gave an type error (LHS: integer, RHS: unknown). While
> class(*), pointer :: p => null(x)
> was accepted without error diagnostic.
>
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
>
> Tobias
> diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
> index 5ed8388..7d49578 100644
> --- a/gcc/fortran/decl.c
> +++ b/gcc/fortran/decl.c
> @@ -1671,11 +1671,31 @@ match
> gfc_match_null (gfc_expr **result)
> {
> gfc_symbol *sym;
> - match m;
> + match m, m2 = MATCH_NO;
>
> - m = gfc_match (" null ( )");
> - if (m != MATCH_YES)
> - return m;
> + if ((m = gfc_match (" null ( )")) == MATCH_ERROR)
> + return MATCH_ERROR;
> +
> + if (m == MATCH_NO)
> + {
> + locus old_loc;
> + char name[GFC_MAX_SYMBOL_LEN + 1];
> +
> + if ((m2 = gfc_match (" null (", name)) != MATCH_YES)
It seems the `name' argument to `gfc_match' is superfluous here.
Thanks for the patch.
Mikael
More information about the Fortran
mailing list