aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorAndrzej Warzynski <andrzej.warzynski@arm.com>2021-10-14 08:07:30 +0000
committerAndrzej Warzynski <andrzej.warzynski@arm.com>2021-12-17 10:05:28 +0000
commitd18a9aeae9e6b7514186188ba71d1d9b6956fe16 (patch)
treeb2a826e16dd1d554992d222c5512c203dce75e67 /flang/lib/Frontend/CompilerInvocation.cpp
parent78a392cf9f3420f36e4252535d2a6792e02703fa (diff)
downloadllvm-d18a9aeae9e6b7514186188ba71d1d9b6956fe16.zip
llvm-d18a9aeae9e6b7514186188ba71d1d9b6956fe16.tar.gz
llvm-d18a9aeae9e6b7514186188ba71d1d9b6956fe16.tar.bz2
[flang] Make the frontend driver error out when requesting multiple actions
With this change, the following invocations will be treated as errors (multiple actions are specified): ``` $ flang-new -fc1 -E -fsyntax-only file.95 $ flang-new -fc1 -fsyntax-only -fdebug-dump-symbols file.95 ``` In the examples above it is not clear whether it is `-fsyntax-only` or the other action that is run (i.e. `-E` or `-fdebug-dump-symbols`). It makes sense to disallow such usage. This should also lead to cleaner and clearer tests (the `RUN` lines using `%flang_fc1` will only allow one action). This change means that `flang-new -fc1` and `clang -cc1` will behave differently when multiple action options are specified. As frontend drivers are mostly used by compiler developers, this shouldn't affect or confuse the compiler end-users. Also, `flang-new` and `clang` remain consistent. Tests are updated accordingly. More specifically, I've made sure that every test specifies only one action. I've also taken the opportunity to simplify "multiple-input-files.f90" a bit. Differential Revision: https://reviews.llvm.org/D111781
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index acdfcb8..159c563 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -107,6 +107,16 @@ static bool ParseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
// By default the frontend driver creates a ParseSyntaxOnly action.
opts.programAction = ParseSyntaxOnly;
+ // Treat multiple action options as an invocation error. Note that `clang
+ // -cc1` does accept multiple action options, but will only consider the
+ // rightmost one.
+ if (args.hasMultipleArgs(clang::driver::options::OPT_Action_Group)) {
+ const unsigned diagID = diags.getCustomDiagID(
+ clang::DiagnosticsEngine::Error, "Only one action option is allowed");
+ diags.Report(diagID);
+ return false;
+ }
+
// Identify the action (i.e. opts.ProgramAction)
if (const llvm::opt::Arg *a =
args.getLastArg(clang::driver::options::OPT_Action_Group)) {