Skip to content

Commit a4b2f4a

Browse files
authored
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.
1 parent 3fa65de commit a4b2f4a

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
@@ -5362,11 +5362,11 @@ void Driver::BuildJobs(Compilation &C) const {
53625362
});
53635363
}
53645364

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

53715371
// Claim -fdriver-only here.
53725372
(void)C.getArgs().hasArg(options::OPT_fdriver_only);
@@ -5420,7 +5420,7 @@ void Driver::BuildJobs(Compilation &C) const {
54205420
!C.getActions().empty()) {
54215421
Diag(diag::err_drv_unsupported_opt_for_target)
54225422
<< A->getSpelling() << getTargetTriple();
5423-
} else {
5423+
} else if (ReportUnusedArguments) {
54245424
Diag(clang::diag::warn_drv_unused_argument)
54255425
<< A->getAsString(C.getArgs());
54265426
}

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)