[clang] a4b2f4a - Check for unsupported target options even with -Qunused-arguments (#141698)
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 28 11:42:51 PDT 2025
Author: Matthias Braun
Date: 2025-05-28T11:42:47-07:00
New Revision: a4b2f4a72aa9b4655ecc723838830e0a7f29c9ca
URL: https://github.com/llvm/llvm-project/commit/a4b2f4a72aa9b4655ecc723838830e0a7f29c9ca
DIFF: https://github.com/llvm/llvm-project/commit/a4b2f4a72aa9b4655ecc723838830e0a7f29c9ca.diff
LOG: Check for unsupported target options even with -Qunused-arguments (#141698)
Fix clang accidentally skipping checks for
`err_drv_unsupported_opt_for_target` when `-Qunused-arguments` was
active.
Added:
Modified:
clang/lib/Driver/Driver.cpp
clang/test/Driver/unsupported-option.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a5a0393ad7912..6aa0f4c9b1584 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -5362,11 +5362,11 @@ void Driver::BuildJobs(Compilation &C) const {
});
}
- // If the user passed -Qunused-arguments or there were errors, don't warn
- // about any unused arguments.
- if (Diags.hasErrorOccurred() ||
- C.getArgs().hasArg(options::OPT_Qunused_arguments))
- return;
+ // If the user passed -Qunused-arguments or there were errors, don't
+ // warn about any unused arguments.
+ bool ReportUnusedArguments =
+ !Diags.hasErrorOccurred() &&
+ !C.getArgs().hasArg(options::OPT_Qunused_arguments);
// Claim -fdriver-only here.
(void)C.getArgs().hasArg(options::OPT_fdriver_only);
@@ -5420,7 +5420,7 @@ void Driver::BuildJobs(Compilation &C) const {
!C.getActions().empty()) {
Diag(diag::err_drv_unsupported_opt_for_target)
<< A->getSpelling() << getTargetTriple();
- } else {
+ } else if (ReportUnusedArguments) {
Diag(clang::diag::warn_drv_unused_argument)
<< A->getAsString(C.getArgs());
}
diff --git a/clang/test/Driver/unsupported-option.c b/clang/test/Driver/unsupported-option.c
index af836cf003374..7234e52571582 100644
--- a/clang/test/Driver/unsupported-option.c
+++ b/clang/test/Driver/unsupported-option.c
@@ -27,3 +27,8 @@
// RUN: not %clang --target=x86_64 -### -mhtm -lc %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=UNSUP_OPT
// UNSUP_OPT: error: unsupported option
+
+
+// RUN: not %clang -c -Qunused-arguments --target=aarch64-- -mfpu=crypto-neon-fp-armv8 %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=QUNUSED_ARGUMENTS
+// QUNUSED_ARGUMENTS: error: unsupported option '-mfpu=' for target 'aarch64--'
More information about the cfe-commits
mailing list