| Issue |
114064
|
| Summary |
[flang] Flang fails to scan a Fortran file with preprocessor macros
|
| Labels |
flang
|
| Assignees |
|
| Reporter |
inaki-amatria
|
- `flang` version is: `flang version 20.0.0git (https://github.com/llvm/llvm-project.git 6233346895abfb57782511cddc263d439fdd537b)`
- Reduced test case:
```f90
! foo.F
#define BAR(A, B) ((A) * 10000 + (B) * 100)
#define FOO(A, B, C, AA, BB) ( \
(defined(AA) && defined(BB)) && \
(BAR(A, B) C BAR(AA, BB)))
#if FOO(9, 5, >, BAZ, FUX)
#endif
```
- `flang` invocation is: `flang -c foo.F`
- Expected behavior is: The code compiles successfully.
- Actual behavior: Compilation aborts with the following error:
```
error: Could not scan foo.F
foo.F:6:5: error: expected ')'
#if FOO(9, 5, >, BAZ, FUX)
^^^^^^
foo.F:2:30: in a macro defined here
#define FOO(A, B, C, AA, BB) ( \
^^
that expanded to:
( (defined(BAZ) && defined(FUX)) && (((9) * 10000 + ( 5) * 100) > ((BAZ) * 10000 + ( FUX) * 100)))
^
```
- Additional info: The following reduced test case also reproduces the issue:
```f90
#define FOO() (defined(BAR))
#if FOO()
#endif
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs