This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, fortran] PR68566 ICE on using unusable array in reshape
- From: Dominique d'HumiÃres <dominiq at lps dot ens dot fr>
- To: "jvdelisle at charter dot net" <jvdelisle at charter dot net>
- Cc: fortran at gcc dot gnu dot org, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 2 Apr 2016 14:42:54 +0200
- Subject: Re: [patch, fortran] PR68566 ICE on using unusable array in reshape
- Authentication-results: sourceware.org; auth=none
- References: <C647A1A2-F258-41DE-B5E2-19C615E5A379 at lps dot ens dot fr>
> Le 2 avr. 2016 Ã 11:44, Dominique d'HumiÃres <dominiq@lps.ens.fr> a Ãcrit :
>
> Hi Jerry,
>
>> ...
>> I will add an additional test case for the original posted problem in the PR.
>> Two existing tests get exercised, changing the error message. Finding the
>> problems earlier in the matchers I think is the right way to go. I am curious if
>> the old checks ever get triggered (I will look into that a little later.
>
> (2) Before your patch the errors were
>
> Error: Expression at (1) must be of INTEGER type, found REAL
>
> How difficult is it to restore the "found â Â ?
--- ../_clean/gcc/fortran/array.c 2016-01-04 19:51:09.000000000 +0100
+++ gcc/fortran/array.c 2016-04-02 14:31:08.000000000 +0200
@@ -421,10 +421,15 @@ match_array_element_spec (gfc_array_spec
if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
return AS_UNKNOWN;
- if ((*upper)->expr_type == EXPR_FUNCTION && (*upper)->ts.type == BT_UNKNOWN
- && (*upper)->symtree && strcmp ((*upper)->symtree->name, "null") == 0)
+ if (((*upper)->expr_type == EXPR_CONSTANT
+ && (*upper)->ts.type != BT_INTEGER) ||
+ ((*upper)->expr_type == EXPR_FUNCTION
+ && (*upper)->ts.type == BT_UNKNOWN
+ && (*upper)->symtree
+ && strcmp ((*upper)->symtree->name, "null") == 0))
{
- gfc_error ("Expecting a scalar INTEGER expression at %C");
+ gfc_error ("Expecting a scalar INTEGER expression at %C, found %s",
+ gfc_basic_typename ((*upper)->ts.type));
return AS_UNKNOWN;
}
@@ -448,10 +453,16 @@ match_array_element_spec (gfc_array_spec
if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
return AS_UNKNOWN;
- if ((*upper)->expr_type == EXPR_FUNCTION && (*upper)->ts.type == BT_UNKNOWN
- && (*upper)->symtree && strcmp ((*upper)->symtree->name, "null") == 0)
- {
- gfc_error ("Expecting a scalar INTEGER expression at %C");
+ if (((*upper)->expr_type == EXPR_CONSTANT
+ && (*upper)->ts.type != BT_INTEGER) ||
+ ((*upper)->expr_type == EXPR_FUNCTION
+ && (*upper)->ts.type == BT_UNKNOWN
+ && (*upper)->symtree
+ && strcmp ((*upper)->symtree->name, "null") == 0))
+ {
+ /* gfc_error ("Expecting a scalar INTEGER expression at %C"); */
+ gfc_error ("Expecting a scalar INTEGER expression at %C, found %s",
+ gfc_basic_typename ((*upper)->ts.type));
return AS_UNKNOWN;
}
Does the trick (not regtested yet).
Dominique