Cannot use "H" as loop variable

Compiling this code

$ cat myloop.f 
      PROGRAM  myloop
        INTEGER P1
        INTEGER H,J
C
        P1 = 2
         DO 220 H = 1, P1
C

  220    CONTINUE
C
      RETURN
      END

with flang-new (16.0.4):

$ flang-new -c myloop.f 
./myloop.f:6:13: warning: Possible truncated Hollerith literal
           DO 220 H = 1, P1
              ^^^^^^^^^^^^^
error: Semantic errors in myloop.f
./myloop.f:6:24: error: No explicit type declared for 'P1'
           DO 220 H = 1, P1
                         ^^

Replacing H with J compiles fine.
Replacing P1 in DO loop with 2, compiles with a warning:

$ flang-new -c myloop.f 
./myloop.f:6:13: warning: Possible truncated Hollerith literal
           DO 220 H = 1, 2
              ^^^^^^^^^^^^

This looks wrong.

Already fixed in llvm-project/main.

1 Like

Does it mean 16.0.5 or 17.x release?

Probably 17.x. I advise you to build from source if you can; this is a fast-moving project.