public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Fortran: fix prototype of _gfortran_is_extension_of()
@ 2020-09-06 16:03 FX
  2020-09-07  5:34 ` Thomas Koenig
  0 siblings, 1 reply; 2+ messages in thread
From: FX @ 2020-09-06 16:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran

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

Hi,

The problem was reported in detail here: https://gcc.gnu.org/pipermail/fortran/2020-September/055005.html and in previous messages. When resolving select type constructs, the Fortran front-end is trying to use the _gfortran_is_extension_of() library call (which is also used for the EXTENDS_TYPE_OF Fortran intrinsic). However, in doing so, it is constructing the symbol of the function call without proper formal arguments, which leads to the function call being built with a wrong arg-types in the function type tree.

This has no known impact on most targets, but it does lead to wrong code generation on aarch64-apple-darwin20, which is how this bug was identified. The attached patch simply adds proper formal argument list to the intrinsic call.


Regtested on x86_64-apple-darwin19 and tested on aarch64-apple-darwin20.
OK to commit?

FX

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

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index e4232717e42..fc2431b8aad 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -9637,6 +9637,12 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns)
 	  new_st->expr1->value.function.actual->next = gfc_get_actual_arglist ();
 	  new_st->expr1->value.function.actual->next->expr = gfc_get_variable_expr (st);
 	  new_st->expr1->value.function.actual->next->expr->where = code->loc;
+	  /* Set up types in formal arg list.  */
+	  new_st->expr1->value.function.isym->formal = XCNEW (gfc_intrinsic_arg);
+	  new_st->expr1->value.function.isym->formal->ts = new_st->expr1->value.function.actual->expr->ts;
+	  new_st->expr1->value.function.isym->formal->next = XCNEW (gfc_intrinsic_arg);
+	  new_st->expr1->value.function.isym->formal->next->ts = new_st->expr1->value.function.actual->next->expr->ts;
+
 	  new_st->next = body->next;
 	}
 	if (default_case->next)

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

2020-09-06  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	* resolve.c (resolve_select_type): Provide a formal arg list.


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

* Re: [patch] Fortran: fix prototype of _gfortran_is_extension_of()
  2020-09-06 16:03 [patch] Fortran: fix prototype of _gfortran_is_extension_of() FX
@ 2020-09-07  5:34 ` Thomas Koenig
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2020-09-07  5:34 UTC (permalink / raw)
  To: FX, gcc-patches; +Cc: fortran

Hi FX,

> Regtested on x86_64-apple-darwin19 and tested on aarch64-apple-darwin20.
> OK to commit?

Looks good to me.

Best regards

	Thomas


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

end of thread, other threads:[~2020-09-07  5:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-06 16:03 [patch] Fortran: fix prototype of _gfortran_is_extension_of() FX
2020-09-07  5:34 ` 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).