flang
flang copied to clipboard
Make backslash behaviour compatible with gfortran
There are several issues with the -Mbackslash option.
-
Currently, Flang's default behaviour is not compatible with that of gfortran and ifort (as explained in Arm's own documentation). Some of our users have found it cumbersome to have to add
-Mbackslashor-fno-backslashwhen compiling programs that were originally compiled with gfortran. Can we consider changing Flang's default behaviour to be consistent with gfortran and ifort? -
The documentation for
-Mbackslashand-Mnobackslashis incorrect. Both README.md and Using Flang state the following, which is the opposite of reality (not to mention the unnecessary hyphen):-Mbackslash Treat backslash character like a C-style escape character -Mno-backslash Treat backslash like any other characterContrast this with NVIDIA's documentation for nvfortran:
-Mbackslash instructs the compiler to treat the backslash as a normal character, and not as an escape character in quoted strings. -Mnobackslash instructs the compiler to recognize a backslash as an escape character in quoted strings (in accordance with standard C usage).
I will submit a PR to update the wording in the documentation.
-
It is both counter-intuitive and confusing for
-Mbackslashto mean the same thing as-fno-backslash, and for-Mnobackslashto mean the same thing as-fbackslash. I understand that there may be users that rely on the legacy semantics of these options, so there may not be a lot we can do here.
I propose to stop Flang from enabling the backslash extension by default, to better align with gfortran and ifort, and also to deprecate the -M options in favour of the -f ones.
@mleair @pawosm-arm @shivaramaarao @SouraVX What do you guys think?