]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix ICE when compiling with -fcoarray=single, when derefing a non-array.
authorAndre Vehreschild <vehre@gcc.gnu.org>
Tue, 11 Jun 2024 13:24:55 +0000 (15:24 +0200)
committerAndre Vehreschild <vehre@gcc.gnu.org>
Mon, 17 Jun 2024 07:50:18 +0000 (09:50 +0200)
    PR fortran/96418
    PR fortran/103112

gcc/fortran/ChangeLog:

* trans.cc (gfc_deallocate_with_status): Check that object to deref
is an array, before applying array deref.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray_alloc_comp_3.f08: Moved to...
* gfortran.dg/coarray/alloc_comp_8.f90: ...here.
Should be tested for both -fcoarray=single and lib, resp.
* gfortran.dg/coarray_alloc_comp_4.f08: Fix program name.

gcc/fortran/trans.cc
gcc/testsuite/gfortran.dg/coarray/alloc_comp_8.f90 [moved from gcc/testsuite/gfortran.dg/coarray_alloc_comp_3.f08 with 95% similarity]
gcc/testsuite/gfortran.dg/coarray_alloc_comp_4.f08

index a208afe90ab0ce0e4872b76df81f6f6f74aad288..1335b8cc48bb26929fe4081abdaea2cc413e3b8c 100644 (file)
@@ -1838,7 +1838,8 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg,
          else
            caf_dereg_type = (enum gfc_coarray_deregtype) coarray_dealloc_mode;
        }
-      else if (flag_coarray == GFC_FCOARRAY_SINGLE)
+      else if (flag_coarray == GFC_FCOARRAY_SINGLE
+              && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (pointer)))
        pointer = gfc_conv_descriptor_data_get (pointer);
     }
   else if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (pointer)))
similarity index 95%
rename from gcc/testsuite/gfortran.dg/coarray_alloc_comp_3.f08
rename to gcc/testsuite/gfortran.dg/coarray/alloc_comp_8.f90
index e2037aa58093d0de8c7bd4789f431c1c99f84372..8b1539251298fa077c9ac5edd19c98b1049d4fc8 100644 (file)
@@ -1,12 +1,11 @@
 ! { dg-do run }
-! { dg-options "-fcoarray=lib -lcaf_single" }
 ! { dg-additional-options "-latomic" { target libatomic_available } }
 !
 ! Contributed by Andre Vehreschild
 ! Check that manually freeing components does not lead to a runtime crash,
 ! when the auto-deallocation is taking care.
 
-program coarray_alloc_comp_3
+program alloc_comp_6
   implicit none
 
   type dt
index 6586ec651ddfa58860854e0a10f74bb4a7b83c19..4c71a90af8fa877fae700baf4298bc7ac989bea9 100644 (file)
@@ -5,7 +5,7 @@
 ! Contributed by Andre Vehreschild
 ! Check that sub-components are caf_deregistered and not freed.
 
-program coarray_alloc_comp_3
+program coarray_alloc_comp_4
   implicit none
 
   type dt