public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fortran: Diagnose all operands with constraint violations [PR101337]
@ 2021-10-31 19:50 Bernhard Reutner-Fischer
  2021-11-01  4:22 ` Sandra Loosemore
  0 siblings, 1 reply; 2+ messages in thread
From: Bernhard Reutner-Fischer @ 2021-10-31 19:50 UTC (permalink / raw)
  To: gcc-patches, fortran, Sandra Loosemore
  Cc: Bernhard Reutner-Fischer, Bernhard Reutner-Fischer

From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

	PR fortran/101337

gcc/fortran/ChangeLog:

	* resolve.c (resolve_operator): Continue resolving on op2 error.

---
The PR rightfully notes that we only diagnose the right operator
and do not check the left operator if the right one was faulty.

c407b-2 is one of the testcases with respective XFAILs.
Since that testcase is rather big (and full of errors) i'm listing an
abbreviated version here, including the output we'd generate with the
attached patch.

Note: I did not address the XFAILs! Sandra, please take over if you like
      the patch!

Bootstrapped and regtested without new regressions (XFAILs are
apparently ignored and not flagged if they are auto-fixed).
As said, Sandra please take over, i'm deleting this locally.

$ cat c407b-2-b.f90;echo EOF; gfortran -c c407b-2-b.f90
subroutine s2 (x, y)
  implicit none
  type(*) :: x, y
  integer :: i

  ! relational operations
  if (x & ! { dg-error "Assumed.type" "pr101337, failure to diagnose both operands" { xfail *-*-*} }
      .eq. y) then  ! { dg-error "Assumed.type" }
    return
  end if
  if (.not. (x & ! { dg-error "Assumed.type" "pr101337, failure to diagnose both operands" { xfail *-*-*} }
             .ne. y)) then  ! { dg-error "Assumed.type" }
    return
  end if
  i = (x & ! { dg-error "Assumed.type" "pr101337, failure to diagnose both operands" { xfail *-*-*} }
       + y)  ! { dg-error "Assumed.type" }

end subroutine
EOF
c407b-2-b.f90:8:10:

    8 |       .eq. y) then  ! { dg-error "Assumed.type" }
      |          1
Error: Assumed-type variable y at (1) may only be used as actual argument
c407b-2-b.f90:7:6:

    7 |   if (x & ! { dg-error "Assumed.type" "pr101337, failure to diagnose both operands" { xfail *-*-*} }
      |      1
Error: Assumed-type variable x at (1) may only be used as actual argument
c407b-2-b.f90:12:17:

   12 |              .ne. y)) then  ! { dg-error "Assumed.type" }
      |                 1
Error: Assumed-type variable y at (1) may only be used as actual argument
c407b-2-b.f90:11:13:

   11 |   if (.not. (x & ! { dg-error "Assumed.type" "pr101337, failure to diagnose both operands" { xfail *-*-*} }
      |             1
Error: Assumed-type variable x at (1) may only be used as actual argument
c407b-2-b.f90:16:10:

   16 |        + y)  ! { dg-error "Assumed.type" }
      |          1
Error: Assumed-type variable y at (1) may only be used as actual argument
c407b-2-b.f90:15:7:

   15 |   i = (x & ! { dg-error "Assumed.type" "pr101337, failure to diagnose both operands" { xfail *-*-*} }
      |       1
Error: Assumed-type variable x at (1) may only be used as actual argument
---
 gcc/fortran/resolve.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 1f4abd08720..705d2326a29 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -4064,7 +4064,7 @@ resolve_operator (gfc_expr *e)
     {
     default:
       if (!gfc_resolve_expr (e->value.op.op2))
-	return false;
+	t = false;
 
     /* Fall through.  */
 
@@ -4091,6 +4091,9 @@ resolve_operator (gfc_expr *e)
   op2 = e->value.op.op2;
   if (op1 == NULL && op2 == NULL)
     return false;
+  /* Error out if op2 did not resolve. We already diagnosed op1.  */
+  if (t == false)
+    return false;
 
   dual_locus_error = false;
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fortran: Diagnose all operands with constraint violations [PR101337]
  2021-10-31 19:50 [PATCH] Fortran: Diagnose all operands with constraint violations [PR101337] Bernhard Reutner-Fischer
@ 2021-11-01  4:22 ` Sandra Loosemore
  0 siblings, 0 replies; 2+ messages in thread
From: Sandra Loosemore @ 2021-11-01  4:22 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer, gcc-patches, fortran; +Cc: Bernhard Reutner-Fischer

On 10/31/21 1:50 PM, Bernhard Reutner-Fischer wrote:
> From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
> 
> 	PR fortran/101337
> 
> gcc/fortran/ChangeLog:
> 
> 	* resolve.c (resolve_operator): Continue resolving on op2 error.
> 
> ---
> The PR rightfully notes that we only diagnose the right operator
> and do not check the left operator if the right one was faulty.
> 
> c407b-2 is one of the testcases with respective XFAILs.
> Since that testcase is rather big (and full of errors) i'm listing an
> abbreviated version here, including the output we'd generate with the
> attached patch.
> 
> Note: I did not address the XFAILs! Sandra, please take over if you like
>        the patch!
> 
> Bootstrapped and regtested without new regressions (XFAILs are
> apparently ignored and not flagged if they are auto-fixed).
> As said, Sandra please take over, i'm deleting this locally.

OK, I will take a look at the test results once I reach a good stopping 
point with the other thing I am hacking at present.

-Sandra

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-01  4:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-31 19:50 [PATCH] Fortran: Diagnose all operands with constraint violations [PR101337] Bernhard Reutner-Fischer
2021-11-01  4:22 ` Sandra Loosemore

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).