Skip to content

Commit 89110c5

Browse files
author
Jerry DeLisle
committed
Fortran: Fix wrongly rejected allocatable LOCK_TYPE [PR107406]
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>
1 parent 5cf52e4 commit 89110c5

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

gcc/fortran/parse.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3691,11 +3691,8 @@ check_component (gfc_symbol *sym, gfc_component *c, gfc_component **lockp,
36913691
"of type LOCK_TYPE, which must have a codimension or be a "
36923692
"subcomponent of a coarray", c->name, &c->loc);
36933693

3694-
if (lock_type && allocatable && !coarray)
3695-
gfc_error ("Allocatable component %s at %L of type LOCK_TYPE must have "
3696-
"a codimension", c->name, &c->loc);
3697-
else if (lock_type && allocatable && c->ts.type == BT_DERIVED
3698-
&& c->ts.u.derived->attr.lock_comp)
3694+
if (lock_type && allocatable && !coarray && c->ts.type == BT_DERIVED
3695+
&& c->ts.u.derived->attr.lock_comp)
36993696
gfc_error ("Allocatable component %s at %L must have a codimension as "
37003697
"it has a noncoarray subcomponent of type LOCK_TYPE",
37013698
c->name, &c->loc);

gcc/testsuite/gfortran.dg/coarray_lock_3.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end module m
2424
module m2
2525
use iso_fortran_env
2626
type t2
27-
type(lock_type), allocatable :: x ! { dg-error "Allocatable component x at .1. of type LOCK_TYPE must have a codimension" }
27+
type(lock_type), allocatable :: x
2828
end type t2
2929
end module m2
3030

gcc/testsuite/gfortran.dg/coarray_lock_4.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ subroutine more_tests
4949
type(t1) :: x1 ! OK
5050

5151
type t2
52-
type(lock_type), allocatable :: c1(:) ! { dg-error "Allocatable component c1 at .1. of type LOCK_TYPE must have a codimension" }
52+
type(lock_type), allocatable :: c1(:)
5353
end type t2
5454

5555
type t3

gcc/testsuite/gfortran.dg/coarray_lock_5.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ subroutine test2()
3232
use iso_fortran_env
3333
implicit none
3434
type t
35-
type(lock_type), allocatable :: lock ! { dg-error "Allocatable component lock at .1. of type LOCK_TYPE must have a codimension" }
35+
type(lock_type), allocatable :: lock
3636
end type t
3737
type t2
3838
type(lock_type) :: lock

0 commit comments

Comments
 (0)