Skip to content

Commit f9b27d2

Browse files
MatzeBgithub-actions[bot]
authored andcommitted
Automerge: 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.
2 parents aef1e03 + a4b2f4a commit f9b27d2

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5365,11 +5365,11 @@ void Driver::BuildJobs(Compilation &C) const {
53655365
});
53665366
}
53675367

5368-
// If the user passed -Qunused-arguments or there were errors, don't warn
5369-
// about any unused arguments.
5370-
if (Diags.hasErrorOccurred() ||
5371-
C.getArgs().hasArg(options::OPT_Qunused_arguments))
5372-
return;
5368+
// If the user passed -Qunused-arguments or there were errors, don't
5369+
// warn about any unused arguments.
5370+
bool ReportUnusedArguments =
5371+
!Diags.hasErrorOccurred() &&
5372+
!C.getArgs().hasArg(options::OPT_Qunused_arguments);
53735373

53745374
// Claim -fdriver-only here.
53755375
(void)C.getArgs().hasArg(options::OPT_fdriver_only);
@@ -5423,7 +5423,7 @@ void Driver::BuildJobs(Compilation &C) const {
54235423
!C.getActions().empty()) {
54245424
Diag(diag::err_drv_unsupported_opt_for_target)
54255425
<< A->getSpelling() << getTargetTriple();
5426-
} else {
5426+
} else if (ReportUnusedArguments) {
54275427
Diag(clang::diag::warn_drv_unused_argument)
54285428
<< A->getAsString(C.getArgs());
54295429
}

clang/test/Driver/unsupported-option.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@
2727
// RUN: not %clang --target=x86_64 -### -mhtm -lc %s 2>&1 \
2828
// RUN: | FileCheck %s -check-prefix=UNSUP_OPT
2929
// UNSUP_OPT: error: unsupported option
30+
31+
32+
// RUN: not %clang -c -Qunused-arguments --target=aarch64-- -mfpu=crypto-neon-fp-armv8 %s 2>&1 \
33+
// RUN: | FileCheck %s --check-prefix=QUNUSED_ARGUMENTS
34+
// QUNUSED_ARGUMENTS: error: unsupported option '-mfpu=' for target 'aarch64--'

0 commit comments

Comments
 (0)