aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 05b03ba..d68534d 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -40,6 +40,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
+#include <algorithm>
#include <cstdlib>
#include <memory>
#include <optional>
@@ -830,14 +831,20 @@ static bool parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
unsigned numErrorsBefore = diags.getNumErrors();
// -J/module-dir option
- auto moduleDirList =
+ std::vector<std::string> moduleDirList =
args.getAllArgValues(clang::driver::options::OPT_module_dir);
- // User can only specify -J/-module-dir once
+ // User can only specify one -J/-module-dir directory, but may repeat
+ // -J/-module-dir as long as the directory is the same each time.
// https://gcc.gnu.org/onlinedocs/gfortran/Directory-Options.html
+ std::sort(moduleDirList.begin(), moduleDirList.end());
+ moduleDirList.erase(std::unique(moduleDirList.begin(), moduleDirList.end()),
+ moduleDirList.end());
if (moduleDirList.size() > 1) {
const unsigned diagID =
diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
- "Only one '-module-dir/-J' option allowed");
+ "Only one '-module-dir/-J' directory allowed. "
+ "'-module-dir/-J' may be given multiple times "
+ "but the directory must be the same each time.");
diags.Report(diagID);
}
if (moduleDirList.size() == 1)