public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR fortran/99853 - ICE: Cannot convert 'LOGICAL(4)' to 'INTEGER(8)' (etc.)
@ 2021-10-28 21:03 Harald Anlauf
  2021-10-29 18:19 ` Bernhard Reutner-Fischer
  2021-10-30 16:24 ` Harald Anlauf
  0 siblings, 2 replies; 4+ messages in thread
From: Harald Anlauf @ 2021-10-28 21:03 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 733 bytes --]

Dear Fortranners,

the original fix by Steve was lingering in the PR.

We did ICE in situations where in a SELECT CASE a kind conversion
was deemed necessary, but it did involve different types.
The check gfc_convert_type_warn () was invoked with arguments
requesting to generate an internal error.  A regular gfc_error
is good enough here.

Regtested on x86_64-pc-linux-gnu.  OK?

Thanks, also to Steve,

Harald


Fortran: generate regular error on invalid conversions of CASE expressions

gcc/fortran/ChangeLog:

	PR fortran/99853
	* resolve.c (resolve_select): Generate regular gfc_error on
	invalid conversions instead of an gfc_internal_error.

gcc/testsuite/ChangeLog:

	PR fortran/99853
	* gfortran.dg/pr99853.f90: New test.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr99853.patch --]
[-- Type: text/x-patch, Size: 1685 bytes --]

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index af71b132dec..8da396b32ec 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -8770,11 +8770,11 @@ resolve_select (gfc_code *code, bool select_type)

 	      if (cp->low != NULL
 		  && case_expr->ts.kind != gfc_kind_max(case_expr, cp->low))
-		gfc_convert_type_warn (case_expr, &cp->low->ts, 2, 0);
+		gfc_convert_type_warn (case_expr, &cp->low->ts, 1, 0);

 	      if (cp->high != NULL
 		  && case_expr->ts.kind != gfc_kind_max(case_expr, cp->high))
-		gfc_convert_type_warn (case_expr, &cp->high->ts, 2, 0);
+		gfc_convert_type_warn (case_expr, &cp->high->ts, 1, 0);
 	    }
 	 }
     }
diff --git a/gcc/testsuite/gfortran.dg/pr99853.f90 b/gcc/testsuite/gfortran.dg/pr99853.f90
new file mode 100644
index 00000000000..421a656bec2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr99853.f90
@@ -0,0 +1,29 @@
+! { dg-do compile }
+! { dg-options "-std=f2018" }
+! PR fortran/99853
+
+subroutine s1 ()
+  select case (.true.) ! { dg-error "Cannot convert" }
+  case (1_8)           ! { dg-error "must be of type LOGICAL" }
+  end select
+end
+
+subroutine s2 ()
+  select case (.false._1) ! { dg-error "Cannot convert" }
+  case (2:3)              ! { dg-error "must be of type LOGICAL" }
+  end select
+end
+
+subroutine s3 ()
+  select case (3_2) ! { dg-error "Cannot convert" }
+  case (.false.)    ! { dg-error "must be of type INTEGER" }
+  end select
+end
+
+subroutine s4 (i)
+  select case (i) ! { dg-error "Cannot convert" }
+  case (.true._8) ! { dg-error "must be of type INTEGER" }
+  end select
+end
+
+! { dg-prune-output "Cannot convert" }

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

* Re: [PATCH] PR fortran/99853 - ICE: Cannot convert 'LOGICAL(4)' to 'INTEGER(8)' (etc.)
  2021-10-28 21:03 [PATCH] PR fortran/99853 - ICE: Cannot convert 'LOGICAL(4)' to 'INTEGER(8)' (etc.) Harald Anlauf
@ 2021-10-29 18:19 ` Bernhard Reutner-Fischer
  2021-10-30 16:24 ` Harald Anlauf
  1 sibling, 0 replies; 4+ messages in thread
From: Bernhard Reutner-Fischer @ 2021-10-29 18:19 UTC (permalink / raw)
  To: Harald Anlauf via Fortran; +Cc: rep.dot.nop, Harald Anlauf, gcc-patches

On Thu, 28 Oct 2021 23:03:05 +0200
Harald Anlauf via Fortran <fortran@gcc.gnu.org> wrote:

> Dear Fortranners,
> 
> the original fix by Steve was lingering in the PR.
> 
> We did ICE in situations where in a SELECT CASE a kind conversion
> was deemed necessary, but it did involve different types.
> The check gfc_convert_type_warn () was invoked with arguments
> requesting to generate an internal error.  A regular gfc_error
> is good enough here.
> 
> Regtested on x86_64-pc-linux-gnu.  OK?

Sounds plausible but i cannot approve it.
PS:
git commit --author 'Steve Kargl <sgk@troutmask.apl.washington.edu>'
would give Steve due credit i suppose. Or throw in --amend if you
applied it already to your local tree (e.g rebase -i and reword the
message, then git commit --amend --author ...). HTH.
> 
> Thanks, also to Steve,

thanks,
> 
> Harald
> 
> 
> Fortran: generate regular error on invalid conversions of CASE expressions
> 
> gcc/fortran/ChangeLog:
> 
> 	PR fortran/99853
> 	* resolve.c (resolve_select): Generate regular gfc_error on
> 	invalid conversions instead of an gfc_internal_error.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR fortran/99853
> 	* gfortran.dg/pr99853.f90: New test.
> 


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

* Re: [PATCH] PR fortran/99853 - ICE: Cannot convert 'LOGICAL(4)' to 'INTEGER(8)' (etc.)
  2021-10-28 21:03 [PATCH] PR fortran/99853 - ICE: Cannot convert 'LOGICAL(4)' to 'INTEGER(8)' (etc.) Harald Anlauf
  2021-10-29 18:19 ` Bernhard Reutner-Fischer
@ 2021-10-30 16:24 ` Harald Anlauf
  2021-10-30 16:24   ` Harald Anlauf
  1 sibling, 1 reply; 4+ messages in thread
From: Harald Anlauf @ 2021-10-30 16:24 UTC (permalink / raw)
  To: fortran, gcc-patches

Committed as simple and obvious after discussion in PR.

Harald

Am 28.10.21 um 23:03 schrieb Harald Anlauf via Fortran:
> Dear Fortranners,
>
> the original fix by Steve was lingering in the PR.
>
> We did ICE in situations where in a SELECT CASE a kind conversion
> was deemed necessary, but it did involve different types.
> The check gfc_convert_type_warn () was invoked with arguments
> requesting to generate an internal error.  A regular gfc_error
> is good enough here.
>
> Regtested on x86_64-pc-linux-gnu.  OK?
>
> Thanks, also to Steve,
>
> Harald
>
>
> Fortran: generate regular error on invalid conversions of CASE expressions
>
> gcc/fortran/ChangeLog:
>
> 	PR fortran/99853
> 	* resolve.c (resolve_select): Generate regular gfc_error on
> 	invalid conversions instead of an gfc_internal_error.
>
> gcc/testsuite/ChangeLog:
>
> 	PR fortran/99853
> 	* gfortran.dg/pr99853.f90: New test.
>


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

* Re: [PATCH] PR fortran/99853 - ICE: Cannot convert 'LOGICAL(4)' to 'INTEGER(8)' (etc.)
  2021-10-30 16:24 ` Harald Anlauf
@ 2021-10-30 16:24   ` Harald Anlauf
  0 siblings, 0 replies; 4+ messages in thread
From: Harald Anlauf @ 2021-10-30 16:24 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

Committed as simple and obvious after discussion in PR.

Harald

Am 28.10.21 um 23:03 schrieb Harald Anlauf via Fortran:
> Dear Fortranners,
> 
> the original fix by Steve was lingering in the PR.
> 
> We did ICE in situations where in a SELECT CASE a kind conversion
> was deemed necessary, but it did involve different types.
> The check gfc_convert_type_warn () was invoked with arguments
> requesting to generate an internal error.  A regular gfc_error
> is good enough here.
> 
> Regtested on x86_64-pc-linux-gnu.  OK?
> 
> Thanks, also to Steve,
> 
> Harald
> 
> 
> Fortran: generate regular error on invalid conversions of CASE expressions
> 
> gcc/fortran/ChangeLog:
> 
> 	PR fortran/99853
> 	* resolve.c (resolve_select): Generate regular gfc_error on
> 	invalid conversions instead of an gfc_internal_error.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR fortran/99853
> 	* gfortran.dg/pr99853.f90: New test.
> 



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

end of thread, other threads:[~2021-10-30 16:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 21:03 [PATCH] PR fortran/99853 - ICE: Cannot convert 'LOGICAL(4)' to 'INTEGER(8)' (etc.) Harald Anlauf
2021-10-29 18:19 ` Bernhard Reutner-Fischer
2021-10-30 16:24 ` Harald Anlauf
2021-10-30 16:24   ` Harald Anlauf

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