Skip to content

[Flang] Compilation error when jumping out of the DO construct and into another #65036

@ohno-fj

Description

@ohno-fj
Version of flang-new : 18.0.0(c07062a2e9bf9aa1211b958f6bb4c5746139c180)

A program that jump out of a DO construct with a GOTO statement and jump into another DO construct has a warning message output by Flang-new, Gfortran and ifort.
However, only Flang-new subsequently causes a compilation error.

The following are the test program, Flang-new, Gfortran and ifort compilation result.

cvct4213.cmp_3.f:

      PROGRAM CV4213
       INTEGER LOOP
       INTEGER J
       REAL*4 EV10(10)
       DATA EV10/0,3*1,5*-2.5,0/
       REAL*8 DV20(200)
       DATA (DV20(I), I=1,200,2)/1,2,30*5,0,36*4,-1,30*-3/
       DATA (DV20(I), I=2,200,2)/1,2,0,28*5,36*4,-1,32*-3/
       INTEGER I1
       J = 10
       LOOP = 1
       DO I1=1,10
        IF (EV10(J) .EQ. 0) GO TO 29
        J = J - 1
       END DO
   19  WRITE (6, *) 'loop'
       LOOP = 2
       DO J=1,2
        DO I1=2,200,2
         IF (DV20(I1) .LE. 0) THEN
          GO TO 29
         END IF
        END DO
   29   CONTINUE
        GO TO (19), LOOP
       END DO
      END
$ flang-new cvct4213.cmp_3.f
./cvct4213.cmp_3.f:13:9: warning: Label '29' is in a construct that should not be used as a branch target here
          IF (EV10(J) .EQ. 0) GO TO 29
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: loc("/home/ohno/tp/reproducerJ/Metro/cvct_fomp/cvct4213.cmp_3.f":25:9): operand #1 does not dominate this use
error: verification of lowering to FIR failed
$
$ gfortran cvct4213.cmp_3.f
cvct4213.cmp_3.f:24:5:

cvct4213.cmp_3.f:13:72:

         IF (EV10(J) .EQ. 0) GO TO 29
                                                                        2
cvct4213.cmp_3.f:24:5:

    29   CONTINUE
     1
Warning: Legacy Extension: Label at (1) is not in the same block as the GOTO statement at (2)
$
$ ifort cvct4213.cmp_3.f
cvct4213.cmp_3.f(13): warning #6371: A jump into a block from outside the block may have occurred.   [29]
        IF (EV10(J) .EQ. 0) GO TO 29
----------------------------------^
$

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorflang:frontend

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions