<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/127426>127426</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Flang does not work correctly in file containing /* Old style C comments*/ in fixed source form
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ohno-fj
</td>
</tr>
</table>
<pre>
```
Version of flang : 21.0.0(d2047242e6d0f0deb7634ff22ab164354c520c79)/AArch64
```
When building [Opium version 4.1](https://opium.sourceforge.net/), the preprocessor does not work correctly.
File containing `/* Old style C comments */` in `fixed source form` cannot be included.
According to [Fortran Extensions supported by Flang](https://flang.llvm.org/docs/Extensions.html#extensions-deletions-and-legacy-features-supported-by-default), the attached program is correct because:
- Classic C-style /*comments*/ are skipped, so multi-language header files are easier to write and use.
The above program is z001.F.
When `fixed source form` is changed to `free source form`, it is included correctly.
The above program is z002.F90.
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
z001.F:
```fortran
subroutine foo ()
#include "inc.h"
integer :: i
i = VAL
print *,i
end subroutine foo
```
inc.h:
```fortran
/* Old style C comments
*comments
*/
#define VAL 1
```
```
$ flang z001.F -c
error: Could not parse z001.F
./inc.h:1:1: warning: Character in fixed-form label field must be a digit
/* Old style C comments
^
./z001.F:2:1: warning: included here
#include "inc.h"
^^^^^^^^^^^^^^^^
./inc.h:2:2: warning: Character in fixed-form label field must be a digit
*comments
^
./z001.F:2:1: warning: included here
#include "inc.h"
^^^^^^^^^^^^^^^^
./inc.h:3:2: warning: Character in fixed-form label field must be a digit
*/
^
./z001.F:2:1: warning: included here
#include "inc.h"
^^^^^^^^^^^^^^^^
./inc.h:1:2: error: expected declaration construct
/* Old style C comments
^
./z001.F:2:1: error: included here
#include "inc.h"
^^^^^^^^^^^^^^^^
./inc.h:1:1: in the context: specification part
/* Old style C comments
^
./z001.F:2:1: in the context: included here
#include "inc.h"
^^^^^^^^^^^^^^^^
./z001.F:1:7: in the context: SUBROUTINE subprogram
subroutine foo ()
^
./inc.h:2:3: error: expected declaration construct
*comments
^
./z001.F:2:1: error: included here
#include "inc.h"
^^^^^^^^^^^^^^^^
./inc.h:1:1: in the context: specification part
/* Old style C comments
^
./z001.F:2:1: in the context: included here
#include "inc.h"
^^^^^^^^^^^^^^^^
./z001.F:1:7: in the context: SUBROUTINE subprogram
subroutine foo ()
^
./inc.h:3:3: error: expected declaration construct
*/
^
./z001.F:2:1: error: included here
#include "inc.h"
^^^^^^^^^^^^^^^^
./inc.h:1:1: in the context: specification part
/* Old style C comments
^
./z001.F:2:1: in the context: included here
#include "inc.h"
^^^^^^^^^^^^^^^^
./z001.F:1:7: in the context: SUBROUTINE subprogram
subroutine foo ()
^
$
```
```
$ gfortran z001.F -c -save-temps
$ cat z001.f90
# 1 "z001.F"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "z001.F"
subroutine foo ()
# 1 "inc.h" 1
# 3 "z001.F" 2
integer :: i
i = 1
print *,i
end subroutine foo
$
```
```
$ ifx z001.F -c -P
$ cat z001.i
# 1 "z001.F"
subroutine foo ()
# 1 "./inc.h" 1
# 3
# 3 "z001.F" 2
integer :: i
i = 1
print *,i
end subroutine foo
$
```
z002.F90:
```fortran
subroutine foo ()
#include "inc.h"
integer :: i
i = VAL
print *,i
end subroutine foo
```
```
$ flang z002.F90 -c
$
$ flang z002.F90 -c -save-temps
#line "./z002.F90" 1
subroutine foo ()
integer :: i
i = 1
print *,i
end subroutine foo
$
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWFmP2zYQ_jX0y0ACRdny-sEPindVFAiaok3SZ4ocWUxoUSCpPfrrC-pa7-FN9kgQoAsZa4vHzPfNxyGH3Dm1bxC3ZPWOrM4XvPO1sVtTNyaqvixKI2-2JKPjQ_PPaJ0yDZgKKs2bPZA0B5bENKaEnUlGl2u2ZJhJWlGJ5TpLl1XFG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