public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mikael Morin <morin-mikael@orange.fr>
To: Harald Anlauf <anlauf@gmx.de>, fortran <fortran@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fortran: error recovery for invalid types in array constructors [PR107000]
Date: Wed, 5 Oct 2022 10:51:06 +0200	[thread overview]
Message-ID: <1bf3b7b5-39ac-0c94-256c-f739a4746a7b@orange.fr> (raw)
In-Reply-To: <trinity-79a6df2f-08a1-4f6d-9431-70f884d1c05c-1664918395982@3c-app-gmx-bs23>

Hello

Le 04/10/2022 à 23:19, Harald Anlauf via Fortran a écrit :
> Dear all,
> 
> we did not recover well from bad expressions in array constructors,
> especially when there was a typespec and a unary '+' or '-', and
> when the array constructor was used in an arithmetic expression.
> 
> The attached patch introduces an ARITH_INVALID_TYPE that is used
> when we try to recover from these errors, and tries to handle
> all unary and binary arithmetic expressions.
> 

In the PR, you noted an inconsistency in the error message reported, 
depending on the presence or lack of an operator.
I'm not sure you saw the suggestion to do the following in the last 
message I posted:

diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc
index e6e35ef3c42..ed93ddb2882 100644
--- a/gcc/fortran/arith.cc
+++ b/gcc/fortran/arith.cc
@@ -1654,6 +1654,8 @@ eval_intrinsic (gfc_intrinsic_op op,
    else
      rc = reduce_binary (eval.f3, op1, op2, &result);

+  if (rc == ARITH_INVALID_TYPE)
+    goto runtime;

    /* Something went wrong.  */
    if (op == INTRINSIC_POWER && rc == ARITH_PROHIBIT)


In the testcase, it improves the situation slightly.
For example, from:
>     9 |   x = (1.0, 2.0) * [complex :: +'1'] ! { dg-error "Invalid type" }
>       |                1
> Error: Invalid type in arithmetic operation at (1)
to:
>     9 |   x = (1.0, 2.0) * [complex :: +'1'] ! { dg-error "Invalid type" }
>       |                              1
> Error: Operand of unary numeric operator ‘+’ at (1) is UNKNOWN


or from:
>    29 |   print *, 2 * [real :: 0, 1+'1']  ! { dg-error "Invalid type" }
>       |            1
> Error: Invalid type in arithmetic operation at (1)
to:
>    29 |   print *, 2 * [real :: 0, 1+'1']  ! { dg-error "Invalid type" }
>       |                          1
> Error: Operands of binary numeric operator ‘+’ at (1) are INTEGER(4)/CHARACTER(1)

Unfortunately, it doesn't fix the bogus incommensurate arrays errors.



  reply	other threads:[~2022-10-05  8:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-04 21:19 Harald Anlauf
2022-10-05  8:51 ` Mikael Morin [this message]
2022-10-05  9:23   ` Mikael Morin
2022-10-05 21:40     ` [PATCH, v2] " Harald Anlauf
2022-10-06 20:14       ` Mikael Morin
2022-10-06 21:36         ` Harald Anlauf
2022-10-07  8:01           ` Mikael Morin
2022-10-07 18:46             ` Harald Anlauf
2022-10-07 19:47               ` Mikael Morin
2022-10-07 20:26                 ` [PATCH, v3] " Mikael Morin
2022-10-07 21:41                   ` Harald Anlauf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1bf3b7b5-39ac-0c94-256c-f739a4746a7b@orange.fr \
    --to=morin-mikael@orange.fr \
    --cc=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).