<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112604>112604</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Preprocessor duplicates backslashes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cjosey
</td>
</tr>
</table>
<pre>
I was testing Flang 20 (commit: 7cbb36590384b8b71076a91f8958df556d773238) 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`):
```fortran
program main
implicit none
write(*,*) "\"
end program main
```
Run:
```bash
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE1v5CgQ_TX4UmoL4--DD9kkLeUwq9VopTljXLbJYLAonN78-5VxT6YzPbtSixbl4r168KokkZ4sYsfKP1j5lMgtzM536tURvie9G967F7hIgoAUtJ3gbKSdQHBgolFuWXRg-QPUqu_zqmx53hR909cZryvZZmPTls0wlmU11HUu8oaJFrQFCY9f5HeE1btXVCGFbzNa2GgnCDPCn9q-Sug3bQagdwq4MPEIOsBFGwPSXOQ7gd9sTF49rt4pJHIe3Bv6GB21QQJph31nQbll1QZ_OYADeKTNhJTxJ8YfjvXvX0EjK5KS6wHQS_WdjKQZCfotxNiV4JpsXQCPJ-WWXtt4KCo4yHaV8RKGbTVayaCdBTfewn6q58u35_22rVxwAFbx_SnSseWs4ky0LL-m7dv4G50PXtojuno3ebnAIvU1AnrZaXUA6yzeEgEAXLwOyETDxAMTj3FtgQnBysd9jXloB7jH_eA_tl83e19aL2k-QmP00UmtK5ye4YckYPmxOa1rlHiTexdOmTjL1G3ht_zH-vzPiip8vPN9RVflu7z_RvkaDwPN7vIbUTcQ_4vyMsLrRp_sAhTktPvUx2Z40wMOh32NnPa3Po0frmAVj58OJdCjcgsSKOd97KGXEXoX5s9Y9xA6wCi1IdibekZwXk_aSgMUfHQmwWYPsw9pMnT50OatTLDLatFmvOFtmczdoJq8bupR5kWR8bLJq4IPWNTF2BZ12zSJ7gQXRcazKmuLJitTWaiqUaLHbGjzsclYwXGR2qTGvC2p81OiiTbsskxUvEiM7NFQHEtCRANEEz4lvtsPnPptIlZwoynQT4igg4mzLI4pVj7BX7eN_KPh9r792WzJ5k03h7DS_rbizMR50mHe-lS5hYnzjn79O10nFhPnWC0xcb4W_NaJfwMAAP__pU6iDw">