public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR fortran/68544 -- Issue error for derived type used as actual arg
@ 2018-06-11 15:05 Steve Kargl
  2018-06-11 18:28 ` Thomas Koenig
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Kargl @ 2018-06-11 15:05 UTC (permalink / raw)
  To: fortran, gcc-patches

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

The attach patch fixes an ICE that occurs when a user 
uses a derived type as an actual argument to subprogram.
Regression tested on x86_64-*-freebsd and i586-*-freebsd.
OK to commit?

2018-06-10  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68544
	* resolve.c (is_dt_name): New function to compare symbol name against
	list of derived types.
	(resolve_actual_arglist): Use it to find wrong code.

2018-06-10  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68544
	* gfortran.dg/pr68544.f90: New test.
	* gfortran.dg/pr85687.f90: Modify test for new error message.
-- 
Steve

[-- Attachment #2: pr68544.diff --]
[-- Type: text/x-diff, Size: 2391 bytes --]

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 261376)
+++ gcc/fortran/resolve.c	(working copy)
@@ -1862,7 +1862,19 @@ resolve_procedure_expression (gfc_expr* expr)
   return true;
 }
 
+/* Check that name is not a derived type.  */
 
+static bool
+is_dt_name (const char *name)
+{
+  gfc_dt_list *dt_list;
+
+  for (dt_list = gfc_derived_types; dt_list; dt_list = dt_list->next)
+    if (strcmp(dt_list->derived->name, name) == 0)
+      return true;
+  return false;
+}
+
 /* Resolve an actual argument list.  Most of the time, this is just
    resolving the expressions in the list.
    The exception is that we sometimes have to decide whether arguments
@@ -1963,6 +1975,14 @@ resolve_actual_arglist (gfc_actual_arglist *arg, proce
 	      gfc_error ("ELEMENTAL non-INTRINSIC procedure %qs is not "
 			 "allowed as an actual argument at %L", sym->name,
 			 &e->where);
+	    }
+
+	  /* Check to see if the argument is actually a derived type.  */
+	  if (is_dt_name (sym->name))
+	    {
+	      gfc_error ("Derived type %qs is used as an actual "
+			 "argument at %L", sym->name, &e->where);
+	      goto cleanup;
 	    }
 
 	  /* Check if a generic interface has a specific procedure
Index: gcc/testsuite/gfortran.dg/pr68544.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr68544.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr68544.f90	(working copy)
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! PF fortran/68544
+program p
+   real x
+   type t
+   end type
+   x = f(t)             ! { dg-error "used as an actual argument" }
+end
+subroutine b
+   type t
+   end type
+   print *, shape(t)    ! { dg-error "used as an actual argument" }
+end
Index: gcc/testsuite/gfortran.dg/pr85687.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr85687.f90	(revision 261376)
+++ gcc/testsuite/gfortran.dg/pr85687.f90	(working copy)
@@ -1,8 +1,9 @@
 ! { dg-do compile }
 ! PR fortran/85687
 ! Code original contributed by Gerhard Steinmetz gscfq at t-oline dot de
+! Originally, error message superceded by fix for PR fortran/68544.
 program p
    type t
    end type
-   print *, rank(t)  ! { dg-error "must be a data object" }
+   print *, rank(t)  ! { dg-error "used as an actual argument" }
 end

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

* Re: [PATCH] PR fortran/68544 -- Issue error for derived type used as actual arg
  2018-06-11 15:05 [PATCH] PR fortran/68544 -- Issue error for derived type used as actual arg Steve Kargl
@ 2018-06-11 18:28 ` Thomas Koenig
  2018-06-15  8:39   ` Steve Kargl
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2018-06-11 18:28 UTC (permalink / raw)
  To: sgk, fortran, gcc-patches

Hi Steve,

> The attach patch fixes an ICE that occurs when a user
> uses a derived type as an actual argument to subprogram.
> Regression tested on x86_64-*-freebsd and i586-*-freebsd.
> OK to commit?

OK. Thanks!

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

* Re: [PATCH] PR fortran/68544 -- Issue error for derived type used as actual arg
  2018-06-11 18:28 ` Thomas Koenig
@ 2018-06-15  8:39   ` Steve Kargl
  0 siblings, 0 replies; 3+ messages in thread
From: Steve Kargl @ 2018-06-15  8:39 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: fortran, gcc-patches

On Mon, Jun 11, 2018 at 07:59:42PM +0200, Thomas Koenig wrote:
> Hi Steve,
> 
> > The attach patch fixes an ICE that occurs when a user
> > uses a derived type as an actual argument to subprogram.
> > Regression tested on x86_64-*-freebsd and i586-*-freebsd.
> > OK to commit?
> 
> OK. Thanks!

This is on hold until Andrew gets his paperwork through
the FSF gauntlet.  He's patch changes the handling of
the gfc_derived_list, which I also manipulate.

-- 
Steve

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

end of thread, other threads:[~2018-06-15  0:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11 15:05 [PATCH] PR fortran/68544 -- Issue error for derived type used as actual arg Steve Kargl
2018-06-11 18:28 ` Thomas Koenig
2018-06-15  8:39   ` Steve Kargl

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