Issue 129455
Summary [Flang] Preprocessor does not work correctly when C old-style comments immediately precedes a continuation line.
Labels flang
Assignees
Reporter ohno-fj
    ```
Version of flang : 21.0.0(c8b40867d144395ad3c306a3cf87f970e0f97f07)/AArch64
```

`C old-style comments` specified in the program are removed by the preprocessor.  
When `C old-style comments` is specified on the line immediately preceding a continuation line, the continuation of the statement is not successful.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

flang snggo770_2.F90:
```fortran
integer &
i(1)
/* \\\*/
i(1)&
/* \\\*/
=1
/* \*/
if (i(1)/=1)write(6,*)'error',i(1)
print *,'pass'
end
```

```
$ flang snggo770_2.F90
error: Could not parse snggo770_2.F90
./snggo770_2.F90:4:3: error: expected ')'
  i(1)&
    ^
./snggo770_2.F90:4:1: in the context: statement function definition
  i(1)&
  ^
./snggo770_2.F90:4:1: in the context: declaration construct
  i(1)&
  ^
./snggo770_2.F90:1:1: in the context: specification part
  integer &
  ^
./snggo770_2.F90:1:1: in the context: main program
  integer &
  ^
./snggo770_2.F90:6:2: error: expected declaration construct
  =1
   ^
./snggo770_2.F90:1:1: in the context: specification part
  integer &
  ^
./snggo770_2.F90:1:1: in the context: main program
  integer &
  ^
$
```

```
$ flang snggo770_2.F90 -E
#line "./snggo770_2.F90" 1
      integer i(1)


 i(1)

      =1

      if(i(1)/=1)write(6,*)'error',i(1)
      print *,'pass'
      end
$
```

```
$ gfortran snggo770_2.F90; ./a.out
 pass
$
```

```
$ gfortran snggo770_2.F90 -E
# 1 "snggo770_2.F90"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "snggo770_2.F90"
integer &
i(1)

i(1)&

=1

if (i(1)/=1)write(6,*)'error',i(1)
print *,'pass'
end
$
```

```
$ ifx snggo770_2.F90; ./a.out
 pass
$
```

```
$ ifx snggo770_2.F90 -E
# 1 "snggo770_2.F90"
integer &
i(1)

i(1)&

=1

if (i(1)/=1)write(6,*)'error',i(1)
print *,'pass'
end
```


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to