Skip to content

[Flang] Preprocessor duplicates backslashes #112604

Open
@cjosey

Description

@cjosey

I was testing Flang 20 (commit: 7cbb365) in a CMake project. When using the Ninja build system, it will always run the preprocessor over the files and then compile the preprocessed result.

The preprocessor will escape the backslashes but the compiler will not re-combine them, resulting in a duplication of backslashes.

MWE (named test.f90):

program main
    implicit none

    write(*,*) "\"
end program main

Run:

flang -cpp -E test.f90 > test-pp.f90
flang test-pp.f90
./a.out

Expected result:

 \

Result shown:

 \\

If just the compile stages are provided the flag -fbackslash the result becomes correct. If both are provided -fbackslash it fails as the original string is unescaped.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions