Issue 115676
Summary [Flang] Preprocessor does not work correctly in if statement
Labels flang
Assignees
Reporter ohno-fj
    ```
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
$
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to