]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: Fix wrongly rejected allocatable LOCK_TYPE [PR107406]
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Wed, 10 Dec 2025 18:38:29 +0000 (10:38 -0800)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Thu, 11 Dec 2025 22:22:46 +0000 (14:22 -0800)
PR fortran/107406

gcc/fortran/ChangeLog:

* parse.cc (check_component): Adjust the error check to
require a codimension if the allocatable type has
a non-coarray LOCK_TYPE component.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray_lock_3.f90: Remove dg-error on
valid code.
* gfortran.dg/coarray_lock_4.f90: Likewise.
* gfortran.dg/coarray_lock_5.f90: Likwise

Co-Authored by: Andre Vehreschild <vehre@gcc.gnu.org>

gcc/fortran/parse.cc
gcc/testsuite/gfortran.dg/coarray_lock_3.f90
gcc/testsuite/gfortran.dg/coarray_lock_4.f90
gcc/testsuite/gfortran.dg/coarray_lock_5.f90

index df8570bad2891d144ff29efdfde83ecedc6fc917..813c5e3fe4a2ecb74ab52030e22e8f1a87164968 100644 (file)
@@ -3691,11 +3691,8 @@ check_component (gfc_symbol *sym, gfc_component *c, gfc_component **lockp,
                "of type LOCK_TYPE, which must have a codimension or be a "
                "subcomponent of a coarray", c->name, &c->loc);
 
-  if (lock_type && allocatable && !coarray)
-    gfc_error ("Allocatable component %s at %L of type LOCK_TYPE must have "
-               "a codimension", c->name, &c->loc);
-  else if (lock_type && allocatable && c->ts.type == BT_DERIVED
-           && c->ts.u.derived->attr.lock_comp)
+  if (lock_type && allocatable && !coarray && c->ts.type == BT_DERIVED
+      && c->ts.u.derived->attr.lock_comp)
     gfc_error ("Allocatable component %s at %L must have a codimension as "
                "it has a noncoarray subcomponent of type LOCK_TYPE",
                c->name, &c->loc);
index 388857307f05d9382e163875d180602c0fba4773..2aec37172762c5b8c06add963fd035dad492b534 100644 (file)
@@ -24,7 +24,7 @@ end module m
 module m2
   use iso_fortran_env
   type t2
-    type(lock_type), allocatable :: x ! { dg-error "Allocatable component x at .1. of type LOCK_TYPE must have a codimension" }
+    type(lock_type), allocatable :: x
   end type t2
 end module m2
 
index 787dfe042102056d6a127bee2f320c63583e0476..107dc19883f457db01500cda7203510b74508b03 100644 (file)
@@ -49,7 +49,7 @@ subroutine more_tests
   type(t1) :: x1 ! OK
 
   type t2
-    type(lock_type), allocatable :: c1(:) ! { dg-error "Allocatable component c1 at .1. of type LOCK_TYPE must have a codimension" }
+    type(lock_type), allocatable :: c1(:)
   end type t2
 
   type t3
index b419606b0de1e73198ecac5cb34a9d79da6cf50f..a92c7f52d8e553c8b2f0f8106e2e909c0cc16160 100644 (file)
@@ -32,7 +32,7 @@ subroutine test2()
   use iso_fortran_env
   implicit none
   type t
-    type(lock_type), allocatable :: lock ! { dg-error "Allocatable component lock at .1. of type LOCK_TYPE must have a codimension" }
+    type(lock_type), allocatable :: lock
   end type t
   type t2
     type(lock_type) :: lock