<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115676>115676</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Preprocessor does not work correctly in if statement
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ohno-fj
</td>
</tr>
</table>
<pre>
```
Version of flang-new : 20.0.0(74b56c7eb807e2ba54bd7a2bcfda5d0bceff1c0c)/AArch64
```
Preprocessor does not work correctly in if statement.
When I look at the file (`snggo785_2.i`) processed by the preprocessor, lines 3, 5, and 20 are processed correctly, but line 19 is not.
For the following line
```
19 if((1.e.2)/=3) print *,'error-1'
```
Expect to translate as follows
```
19 if((1.eeeee.2)/=3) print *,'error-1'
```
The following are the test program, Flang-new, Gfortran and ifx compilation result.
snggo785_2.F90:
```fortran
#define e eeeee
module m
interface operator(.e.)
module procedure ir,rr
end interface operator(.e.)
contains
function ir(k1,k2)
intent(in)::k1,k2
ir=k1+k2
end function ir
function rr(k1,k2)
real,intent(in)::k1,k2
rr=k1+k2
end function rr
end module m
program main
use m
if((1.e.2)/=3) print *,'error-1'
if(abs((1..e..2)-1.2)>0.001) print *,'error-2'
print *,'pass'
end program main
```
```
$ flang-new snggo785_2.F90 -save-temps
error: Semantic errors in snggo785_2.i
./snggo785_2.F90:19:11: error: No operator .E. defined for INTEGER(4) and INTEGER(4)
if((1.e.2)/=3) print *,'error-1'
^^^^^
$ cat snggo785_2.i -n
1 #line "./snggo785_2.F90" 2
2 module m
3 interface operator(.eeeee.)
4 module procedure ir,rr
5 end interface operator(.eeeee.)
6 contains
7 function ir(k1,k2)
8 intent(in)::k1,k2
9 ir=k1+k2
10 end function ir
11 function rr(k1,k2)
12 real,intent(in)::k1,k2
13 rr=k1+k2
14 end function rr
15 end module m
16
17 program main
18 use m
19 if((1.e.2)/=3) print *,'error-1'
20 if(abs((1..eeeee..2)-1.2)>0.001) print *,'error-2'
21 print *,'pass'
22 end program main
$
```
```
$ gfortran snggo785_2.F90 -save-temps
$ cat a-snggo785_2.f90 -n
1 # 1 "snggo785_2.F90"
2 # 1 "<built-in>"
3 # 1 "<command-line>"
4 # 1 "snggo785_2.F90"
5
6 module m
7 interface operator(.eeeee.)
8 module procedure ir,rr
9 end interface operator(.eeeee.)
10 contains
11 function ir(k1,k2)
12 intent(in)::k1,k2
13 ir=k1+k2
14 end function ir
15 function rr(k1,k2)
16 real,intent(in)::k1,k2
17 rr=k1+k2
18 end function rr
19 end module m
20
21 program main
22 use m
23 if((1.eeeee.2)/=3) print *,'error-1'
24 if(abs((1..eeeee..2)-1.2)>0.001) print *,'error-2'
25 print *,'pass'
26 end program main
$
```
```
$ ifx snggo785_2.F90 -P
$ cat snggo785_2.i90 -n
1 # 1 "snggo785_2.F90"
2
3 module m
4 interface operator(.eeeee.)
5 module procedure ir,rr
6 end interface operator(.eeeee.)
7 contains
8 function ir(k1,k2)
9 intent(in)::k1,k2
10 ir=k1+k2
11 end function ir
12 function rr(k1,k2)
13 real,intent(in)::k1,k2
14 rr=k1+k2
15 end function rr
16 end module m
17
18 program main
19 use m
20 if((1.eeeee.2)/=3) print *,'error-1'
21 if(abs((1..eeeee..2)-1.2)>0.001) print *,'error-2'
22 print *,'pass'
23 end program main
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0mF2P2rwSxz-NuRkR2ZP3Cy7oLlS9qapzqnMuHzmJA-4GG9mmL9_-kQNhkxBY2LbRKqVmPJ4Zz_8XE26t3CghFiT-QOLnGT-4rTYLvVV6Xn-bFbr6tSAJPf3RZ0KX_xPGSq1A11A3XG3mSvwAEi4BaUADSjBLoyJOylQUGU0FFjyOiirlWJR1xeOKFqWoa1bSkmBOcL1cmnKbREfno7WO9y9G7I0uhbXaQKWFBaUd_NDmBUptjChd8wukAlmDddyJnVAuADhO_v9WKPgEjdYvwB24rYBaNgIIZiShV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