This patch adds extra logic in Driver::ParseArgStrings so that clang
(Clang's compiler driver) generates a warning when a Flang-only option
is used. Previously it would throw an error:
- error: unknown argument: <option>
and exit immediately. That was flagged as problematic in [1].
The new behaviour is consistent with GCC:
gcc -c -ffree-form file.c cc1: warning: command line option ‘-ffree-form’ is valid for Fortran but not for C
It allows users to use clang as e.g. a linker driver, without worrying
about passing Fortran specific flags to clang. These flags are often
embedded in build systems and are hard to extract just for linking.
An issue like this raised in [1]. This patch is an attempt to address
this.
The current approach is a bit verbose. Ideally we should extend the
OptTable API to make accommodating for situations like this easier. In
particular, I'm not sure whether we can add similar logic for Flang.
In this patch we are relying on the FlangOnlyOption flag to
identify problematic options. There's no equivalent flag for Clang-only
options. I propose that we address this later, when this becomes a
problem for Flang.
This is how we could deal with aliased options, but currently A->getAlias() always returns nullptr.