Skip to content

Commit f1d75d0

Browse files
[clang][Driver] Don't warn when -nostdinc and -nostdinc++ are both specified (llvm#77130)
When -nostdinc and -nostdinc++ are both specified and the Baremetal toolchain is used, an unused command line argument warning for -nostdinc++ is produced. This doesn't seem particularly meaningful as -nostdinc++ would have been claimed/used had the check in AddClangCXXStdlibIncludeArgs not short-circuited. So, just claim all arguments in this check. I believe this is consistent with what was done for the GNU toolchain (see 6fe7de9), so hopefully this is appropriate here as well.
1 parent 853b133 commit f1d75d0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,8 @@ void BareMetal::addClangTargetOptions(const ArgList &DriverArgs,
293293

294294
void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
295295
ArgStringList &CC1Args) const {
296-
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
297-
DriverArgs.hasArg(options::OPT_nostdlibinc) ||
298-
DriverArgs.hasArg(options::OPT_nostdincxx))
296+
if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
297+
options::OPT_nostdincxx))
299298
return;
300299

301300
const Driver &D = getDriver();

clang/test/Driver/nostdincxx.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: not %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
33
// RUN: not %clangxx -nostdlibinc %s 2>&1 | FileCheck %s
44
// RUN: not %clangxx --target=x86_64-unknown-unknown-gnu -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck /dev/null --implicit-check-not=-Wunused-command-line-argument
5+
// RUN: not %clangxx --target=riscv64-unknown-elf -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck /dev/null --implicit-check-not=-Wunused-command-line-argument
56
// CHECK: 'vector' file not found
67
#include <vector>
78

0 commit comments

Comments
 (0)