public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fortran : ICE in gfc_validate_kind PR96099
@ 2020-10-02  5:51 Mark Eggleston
  2020-10-04 10:33 ` Thomas Koenig
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Eggleston @ 2020-10-02  5:51 UTC (permalink / raw)
  To: gcc-patches, fortran

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

This is a follow up to PR95586 which fixed only the ICE that occurred 
when using derived types in an implicit statement.  The ICE occurred 
because an attempt was made to determine kind for types that do not have 
kinds.

This patch ensures that kind is only determined for types that support kind.

OK for master?

Is it worth backporting?

[PATCH] Fortran  : ICE in gfc_validate_kind PR96099

Only check for kind if the type supports kind.

2020-10-02  Mark Eggleston <markeggleston@gcc.gnu.org>

/gcc/fortran

     PR fortran/96099
     * decl.c (gfc_match_implicit): Check for numeric and logical
     types.

2020-10-02  Mark Eggleston <markeggleston@gcc.gnu.org>

/gcc/testsuite

     PR fortran/96099
     * gfortran.dg/pr96099_1.f90: New test.
     * gfortran.dg/pr96099_2.f90: New test.

-- 
https://www.codethink.co.uk/privacy.html


[-- Attachment #2: 0001-Fortran-ICE-in-gfc_validate_kind-PR96099.patch --]
[-- Type: text/x-patch, Size: 2199 bytes --]

From 8770d2c3f599f8e758747b606613ae53f0b26bc9 Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggleston@gcc.gnu.org>
Date: Thu, 1 Oct 2020 11:14:09 +0100
Subject: [PATCH] Fortran  : ICE in gfc_validate_kind PR96099

Only check for kind if the type supports kind.

2020-10-02  Mark Eggleston  <markeggleston@gcc.gnu.org>

/gcc/fortran

	PR fortran/96099
	* decl.c (gfc_match_implicit): Check for numeric and logical
	types.

2020-10-02  Mark Eggleston  <markeggleston@gcc.gnu.org>

/gcc/testsuite

	PR fortran/96099
	* gfortran.dg/pr96099_1.f90: New test.
	* gfortran.dg/pr96099_2.f90: New test.
---
 gcc/fortran/decl.c                      | 2 +-
 gcc/testsuite/gfortran.dg/pr96099_1.f90 | 8 ++++++++
 gcc/testsuite/gfortran.dg/pr96099_2.f90 | 9 +++++++++
 3 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gfortran.dg/pr96099_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/pr96099_2.f90

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 326e6f5db7a..bddf69cce19 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -4835,7 +4835,7 @@ gfc_match_implicit (void)
       /* Last chance -- check <TYPE> <SELECTOR> (<RANGE>).  */
       if (ts.type == BT_CHARACTER)
 	m = gfc_match_char_spec (&ts);
-      else if (ts.type != BT_DERIVED)
+      else if (gfc_numeric_ts(&ts) || ts.type == BT_LOGICAL)
 	{
 	  m = gfc_match_kind_spec (&ts, false);
 	  if (m == MATCH_NO)
diff --git a/gcc/testsuite/gfortran.dg/pr96099_1.f90 b/gcc/testsuite/gfortran.dg/pr96099_1.f90
new file mode 100644
index 00000000000..9754bd39dfc
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr96099_1.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+
+program pr96099_1
+   implicit class(t) (1) ! { dg-error "Syntax error in IMPLICIT" }
+   type t
+   end type
+end
+
diff --git a/gcc/testsuite/gfortran.dg/pr96099_2.f90 b/gcc/testsuite/gfortran.dg/pr96099_2.f90
new file mode 100644
index 00000000000..3136d2ef377
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr96099_2.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+
+program pr96099_2
+   integer n1
+   parameter (n1 = 1)
+   implicit class(t) (n1) ! { dg-error "Syntax error in IMPLICIT" }
+   type t
+   end type
+end
-- 
2.11.0


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

* Re: [PATCH] Fortran : ICE in gfc_validate_kind PR96099
  2020-10-02  5:51 [PATCH] Fortran : ICE in gfc_validate_kind PR96099 Mark Eggleston
@ 2020-10-04 10:33 ` Thomas Koenig
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2020-10-04 10:33 UTC (permalink / raw)
  To: Mark Eggleston, gcc-patches, fortran

Hi Mark,

> This is a follow up to PR95586 which fixed only the ICE that occurred 
> when using derived types in an implicit statement.  The ICE occurred 
> because an attempt was made to determine kind for types that do not have 
> kinds.
> 
> This patch ensures that kind is only determined for types that support 
> kind.
> 
> OK for master?

OK.

> Is it worth backporting?

As an ICE on invalid for quite a special case, I'd say probably
not.

Thanks for the patch!

Best regards

	Thomas

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

end of thread, other threads:[~2020-10-04 10:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-02  5:51 [PATCH] Fortran : ICE in gfc_validate_kind PR96099 Mark Eggleston
2020-10-04 10:33 ` Thomas Koenig

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