[clang] [flang] [flang][Driver] Better error message when multiple actions are specified (PR #165575)

David Spickett via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 29 09:07:36 PDT 2025


================
@@ -595,9 +595,17 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
   // -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);
+    llvm::SmallString<32> buf;
+    llvm::raw_svector_ostream os(buf);
+    for (const llvm::opt::Arg *arg :
+         args.filtered(clang::driver::options::OPT_Action_Group)) {
+      if (buf.size())
+        os << ", ";
+      os << "'" << arg->getSpelling() << "'";
+    }
+    // The diagnostics engine will add single quotes around the argument to the
+    // error message. Strip the leading and trailing quote from here.
----------------
DavidSpickett wrote:

You can remove the comment now too.

https://github.com/llvm/llvm-project/pull/165575


More information about the cfe-commits mailing list