public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [8/9/10/11 Regression] [OOP] PR fortran/86470 - ICE with OpenMP
@ 2021-01-27 21:30 Harald Anlauf
  2021-01-28  6:57 ` Thomas Koenig
  0 siblings, 1 reply; 3+ messages in thread
From: Harald Anlauf @ 2021-01-27 21:30 UTC (permalink / raw)
  To: fortran, gcc-patches

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

Dear all,

the fix for this ICE is obvious: make gfc_call_malloc behave as documented.
Apparently the special case in question was not exercised in the testsuite.

Regtested on x86_64-pc-linux-gnu.

OK for master / backports?

Should the testcase be moved to the gomp/ subdirectory?

Thanks,
Harald


PR fortran/86470 - ICE with OpenMP, class(*) allocatable

gfc_call_malloc should malloc an area of size 1 if no size given.

gcc/fortran/ChangeLog:

	PR fortran/86470
	* trans.c (gfc_call_malloc): Allocate area of size 1 if passed
	size is NULL (as documented).

gcc/testsuite/ChangeLog:

	PR fortran/86470
	* gfortran.dg/pr86470.f90: New test.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr86470.patch --]
[-- Type: text/x-patch, Size: 1039 bytes --]

diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index a2376917635..ab53fc5f441 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -689,6 +689,9 @@ gfc_call_malloc (stmtblock_t * block, tree type, tree size)
   /* Call malloc.  */
   gfc_start_block (&block2);

+  if (size == NULL_TREE)
+    size = build_int_cst (size_type_node, 1);
+
   size = fold_convert (size_type_node, size);
   size = fold_build2_loc (input_location, MAX_EXPR, size_type_node, size,
 			  build_int_cst (size_type_node, 1));
diff --git a/gcc/testsuite/gfortran.dg/pr86470.f90 b/gcc/testsuite/gfortran.dg/pr86470.f90
new file mode 100644
index 00000000000..4021e5d655c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr86470.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-options "-fopenmp" }
+! PR fortran/86470 - ICE with OpenMP, class(*)
+
+program p
+  implicit none
+  class(*), allocatable :: val
+!$OMP PARALLEL private(val)
+  allocate(integer::val)
+  val = 1
+  deallocate(val)
+!$OMP END PARALLEL
+end

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

* Re: [PATCH] [8/9/10/11 Regression] [OOP] PR fortran/86470 - ICE with OpenMP
  2021-01-27 21:30 [PATCH] [8/9/10/11 Regression] [OOP] PR fortran/86470 - ICE with OpenMP Harald Anlauf
@ 2021-01-28  6:57 ` Thomas Koenig
  2021-01-28  9:22   ` Harald Anlauf
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2021-01-28  6:57 UTC (permalink / raw)
  To: Harald Anlauf, fortran, gcc-patches


Hello Harald,

> OK for master / backports?

OK. It is indeed fairly obvious, as you write.

> Should the testcase be moved to the gomp/ subdirectory?
Yes. It's a compile-time test, and it will then only be run
if the the compiler can do OpenMP.

You will not need the

+! { dg-options "-fopenmp" }

line, then.

Thanks for the patch!

Best regards

	Thomas

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

* Re: [PATCH] [8/9/10/11 Regression] [OOP] PR fortran/86470 - ICE with OpenMP
  2021-01-28  6:57 ` Thomas Koenig
@ 2021-01-28  9:22   ` Harald Anlauf
  0 siblings, 0 replies; 3+ messages in thread
From: Harald Anlauf @ 2021-01-28  9:22 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: fortran, gcc-patches

Hi Thomas,

> > Should the testcase be moved to the gomp/ subdirectory?
> Yes. It's a compile-time test, and it will then only be run
> if the the compiler can do OpenMP.
>
> You will not need the
>
> +! { dg-options "-fopenmp" }
>
> line, then.

Adjusted and committed as r11-6950-g33a7a93218b1393d0135e3c4a9ad9ced87808f5e

> Thanks for the patch!

Thanks,
Harald


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

end of thread, other threads:[~2021-01-28  9:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-27 21:30 [PATCH] [8/9/10/11 Regression] [OOP] PR fortran/86470 - ICE with OpenMP Harald Anlauf
2021-01-28  6:57 ` Thomas Koenig
2021-01-28  9:22   ` Harald Anlauf

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