Fortran : ICE in resolve_fl_procedure PR95708

Message ID 307b7e66-8f8e-43f4-dd13-1a1f714a2523@codethink.co.uk
State New
Headers show
Series
  • Fortran : ICE in resolve_fl_procedure PR95708
Related show

Commit Message

Mark Eggleston June 19, 2020, 7:45 a.m.
Please find attached a fix for PR95708.

OK for commit and backport?

Commit message:

Fortran  : ICE in resolve_fl_procedure PR95708

Now issues an error "Intrinsic procedure 'num_images' not
allowed in PROCEDURE" instead of an ICE.

2020-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran/

     PR fortran/PR95708
     * intrinsic.c (add_functions): Replace CLASS_INQUIRY with
     CLASS_TRANSFORMATIONAL for intrinsic num_images.
     (make_generic): Replace ACTUAL_NO with ACTUAL_YES for
     intrinsic team_number.

2020-06-19  Mark Eggleston <markeggleston@gcc.gnu.org>

gcc/testsuite/

     PR fortran/95708
     * gfortran.dg/pr95708.f90: New test.

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

Comments

Kirill Yukhin via Gcc-patches June 20, 2020, 9:49 a.m. | #1
Hi Mark,

> Please find attached a fix for PR95708.

> 

> OK for commit and backport?


OK (it's a regression, after all).

Thanks!

Regards

	Thomas

Patch

From c5d89e71478d7c022370992dfd7e42dc2b82040a Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggleston@gcc.gnu.org>
Date: Thu, 18 Jun 2020 13:42:58 +0100
Subject: [PATCH] Fortran  : ICE in resolve_fl_procedure PR95708

Now issues an error "Intrinsic procedure 'num_images' not
allowed in PROCEDURE" instead of an ICE.

2020-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran/

	PR fortran/PR95708
	* intrinsic.c (add_functions): Replace CLASS_INQUIRY with
	CLASS_TRANSFORMATIONAL for intrinsic num_images.
	(make_generic): Replace ACTUAL_NO with ACTUAL_YES for
	intrinsic team_number.

2020-06-19  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/

	PR fortran/95708
	* gfortran.dg/pr95708.f90: New test.
---
 gcc/fortran/intrinsic.c               | 6 +++---
 gcc/fortran/resolve.c                 | 1 +
 gcc/testsuite/gfortran.dg/pr95708.f90 | 6 ++++++
 3 files changed, 10 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/pr95708.f90

diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 17f5efc6566..f2f743a2721 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -2733,8 +2733,8 @@  add_functions (void)
 
   make_generic ("null", GFC_ISYM_NULL, GFC_STD_F95);
 
-  add_sym_2 ("num_images", GFC_ISYM_NUM_IMAGES, CLASS_INQUIRY, ACTUAL_NO,
-	     BT_INTEGER, di, GFC_STD_F2008,
+  add_sym_2 ("num_images", GFC_ISYM_NUM_IMAGES, CLASS_TRANSFORMATIONAL,
+	     ACTUAL_NO, BT_INTEGER, di, GFC_STD_F2008,
 	     gfc_check_num_images, gfc_simplify_num_images, NULL,
 	     dist, BT_INTEGER, di, OPTIONAL,
 	     failed, BT_LOGICAL, dl, OPTIONAL);
@@ -3174,7 +3174,7 @@  add_functions (void)
   make_generic ("tanh", GFC_ISYM_TANH, GFC_STD_F77);
 
   add_sym_1 ("team_number", GFC_ISYM_TEAM_NUMBER, CLASS_TRANSFORMATIONAL,
-	     ACTUAL_YES, BT_INTEGER, di, GFC_STD_F2018,
+	     ACTUAL_NO, BT_INTEGER, di, GFC_STD_F2018,
 	     gfc_check_team_number, NULL, gfc_resolve_team_number,
 	     team, BT_DERIVED, di, OPTIONAL);
 
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index aaee5eb6b9b..c53b312f7ed 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -12999,6 +12999,7 @@  resolve_fl_procedure (gfc_symbol *sym, int mp_flag)
 	{
 	  if (arg->sym
 	      && arg->sym->ts.type == BT_DERIVED
+	      && arg->sym->ts.u.derived
 	      && !arg->sym->ts.u.derived->attr.use_assoc
 	      && !gfc_check_symbol_access (arg->sym->ts.u.derived)
 	      && !gfc_notify_std (GFC_STD_F2003, "%qs is of a PRIVATE type "
diff --git a/gcc/testsuite/gfortran.dg/pr95708.f90 b/gcc/testsuite/gfortran.dg/pr95708.f90
new file mode 100644
index 00000000000..32bd324ce15
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95708.f90
@@ -0,0 +1,6 @@ 
+! { dg-do compile }
+!
+
+program test
+  procedure(team_num) :: g ! { dg-error "must be explicit" }
+end program
-- 
2.11.0