This patch adds support for the -cpp and -nocpp flags. The
implemented semantics match f18 (i.e. the "throwaway" driver), but are
different to gfortran. In Flang the preprocessor is always run and
-cpp/-nocpp are only used to control whether standard macro
predefinitions are added or not. In practice this is sufficient to model
gfortran`s -cpp/-nocpp.
In the absence of -cpp/-nocpp, the driver will use the extension of
the input file to decide whether to include the standard macro
predefinitions. gfortran's documentation [1] was used to decide which
file extension to use for this. The extension for:
- predefined-macros-compiler-version.f90
had to be updated accordingly.
The logic mentioned above was added in FrontendAction::BeginSourceFile.
That's relatively late in the driver set-up, but this roughly where the
name of the input file becomes available. The logic for deciding between
fixed and free form works in an a similar way and was also moved to
FrontendAction::BeginSourceFile for consistency (and to reduce
code-duplication).
The -cpp/-nocpp flags are respected also when the input is read from
stdin. This is different to:
- gfortran (behaves as if -cpp was used)
- f18 (behaves as if -nocpp was used)
This option affects command line macro definitions too. So maybe something like:
Enable predefined and command line preprocessor macros