https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107406

Andre Vehreschild <vehre at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vehre at gcc dot gnu.org

--- Comment #5 from Andre Vehreschild <vehre at gcc dot gnu.org> ---
Well, I had a Quick look.

`lock_type` and `lock_comp` are always set together. Therefore `(lock_type &&
... && !lock_comp)` will get rid of the false error in favour of adding dead
code. I therefore propose to remove the first if-block and rather apply:

diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index f987f464023..520867ea45a 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -3684,11 +3684,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);

I tested this on the caf_shmem branch and did not get a single regression,
which I doubt to be correct. Can some one check? I don't have the time to set
it up cleanly.

Reply via email to