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] PR33455 - reject MERGE with character arguments of different length


:REVIEWMAIL:

> 2007-09-21  Tobias Burnus  <burnus@net-b.de>
>
>         PR fortran/33455
>         * check.c (check_same_strlen): New function.
>         (gfc_check_merge): Use it.

OK, with or without the following suggestions. What about making it
available for other intrinsics?

+static try
+check_same_strlen (gfc_expr *a, gfc_expr *b, char *name)
...
+   gfc_error ("Unequal character lengths (%ld and %ld) in %s intrinsic "
+             "at %L", len_a, len_b, name, &a->where);

> +print *, merge(a,   b,    .true.)  ! { dg-error "Unequal character lengths" }
> +print *, merge(a,   'bbb',.true.)  ! { dg-error "Unequal character lengths" }
> +print *, merge('aa',b,    .true.)  ! { dg-error "Unequal character lengths" }
> +print *, merge('aa','bbb',.true.)  ! { dg-error "Unequal character lengths" }

Maybe add tests that don't error out, like:

    print *, merge(a,a,.true.)
    print *, merge(a,'aa',.true.)
    print *, merge('aa',a,.true.)
    print *, merge('aa','bb',.true.)

FX


PS: at some point, we need to stop using mpz_get_si on
sym->ts.cl->length->value.integer, because it might not fit into a
long int. I know this is commonly done in the front-end, but it will
probably come and bite us later.


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