public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fortran: fix another function argtypes bug for ppc
@ 2020-09-06 17:13 FX
  2020-09-06 19:29 ` Thomas Koenig
  0 siblings, 1 reply; 3+ messages in thread
From: FX @ 2020-09-06 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran

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

This is another function argtypes issue, very similar to 

This code from proc_ptr_comp_13.f90 :

------------
! PR 40882: [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type.
! At the same time, check that a formal argument does not cause infinite recursion (PR 40870).
implicit none
type :: t
  procedure(foo), pointer, nopass :: ppc
end type

type(t) :: o, o2
o2 = o%ppc(o)

contains
  function foo(arg)
    type(t) :: foo, arg
  end function
end
------------

causes the compiler to emit wrong code for the call to o%ppc(o), because it gets the type of the function wrong. Again, the intent was to emit an incomplete function type, but this time it is on purpose, and I think unavoidable (to avoid infinite recursion). Except, it was done with the wrong middle-end call. The patch fixes it.

The patch is regtested on x86_64-apple-darwin19.
I also tested it on aarch64-apple-darwin20, where it fixes wrong code issues in several testcases.

OK to commit?

FX


[-- Attachment #2: ppc_dt.diff --]
[-- Type: application/octet-stream, Size: 604 bytes --]

diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index d38aa2865ae..3105a430e54 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -2714,7 +2714,7 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen)
 	field_type = gfc_get_ppc_type (c);
       else if (c->attr.proc_pointer && derived->backend_decl)
 	{
-	  tmp = build_function_type_list (derived->backend_decl, NULL_TREE);
+	  tmp = build_function_type (derived->backend_decl, NULL_TREE);
 	  field_type = build_pointer_type (tmp);
 	}
       else if (c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS)

[-- Attachment #3: ppc_dt.ChangeLog --]
[-- Type: application/octet-stream, Size: 85 bytes --]

gcc/fortran/ChangeLog

	* trans-types.c (gfc_get_derived_type): Fix argument types.


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

* Re: Fortran: fix another function argtypes bug for ppc
  2020-09-06 17:13 Fortran: fix another function argtypes bug for ppc FX
@ 2020-09-06 19:29 ` Thomas Koenig
  2020-09-06 19:53   ` FX
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2020-09-06 19:29 UTC (permalink / raw)
  To: FX, gcc-patches; +Cc: fortran

Hi FX,

> The patch is regtested on x86_64-apple-darwin19.
> I also tested it on aarch64-apple-darwin20, where it fixes wrong code issues in several testcases.

OK (you can also put in a quick FIXME there).

Best regards

	Thomas

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

* Re: Fortran: fix another function argtypes bug for ppc
  2020-09-06 19:29 ` Thomas Koenig
@ 2020-09-06 19:53   ` FX
  0 siblings, 0 replies; 3+ messages in thread
From: FX @ 2020-09-06 19:53 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: gcc-patches, fortran

> OK (you can also put in a quick FIXME there).

Actually the decl being declared is using itself as one of the arguments, so I think it’s on purpose that we don’t want to emit a full arglist here… to avoid recursion. So I’m not sure we would want to change that.

FX

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

end of thread, other threads:[~2020-09-06 19:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-06 17:13 Fortran: fix another function argtypes bug for ppc FX
2020-09-06 19:29 ` Thomas Koenig
2020-09-06 19:53   ` FX

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