diff mbox series

[8/9/10/11,Regression,OOP] PR fortran/86470 - ICE with OpenMP

Message ID trinity-3e3e52c2-0bed-45f6-a6a6-4ae473861eb5-1611783058046@3c-app-gmx-bs28
State New
Headers show
Series None | expand

Commit Message

Harald Anlauf Jan. 27, 2021, 9:30 p.m. UTC
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.

Comments

Thomas Koenig Jan. 28, 2021, 6:57 a.m. UTC | #1
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
Harald Anlauf Jan. 28, 2021, 9:22 a.m. UTC | #2
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
diff mbox series

Patch

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