https://github.com/ilovepi created https://github.com/llvm/llvm-project/pull/104477
Claim `-c` when using `-S`, so that we don't warn for unused arguments when they are used together without `-fsyntax-only`. Fixes #104347 >From 0af4f441447f39df7f496e62f8620d9c8404a5d2 Mon Sep 17 00:00:00 2001 From: Paul Kirth <paulki...@google.com> Date: Thu, 15 Aug 2024 10:52:13 -0700 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- clang/lib/Driver/Driver.cpp | 1 + clang/test/Driver/warn-fsyntax-only.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e12416e51f8d24..0b6bc43dfebb17 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -377,6 +377,7 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL, // -S only runs up to the backend. } else if ((PhaseArg = DAL.getLastArg(options::OPT_S))) { FinalPhase = phases::Backend; + DAL.ClaimAllArgs(options::OPT_c); // -c compilation only runs up to the assembler. } else if ((PhaseArg = DAL.getLastArg(options::OPT_c))) { diff --git a/clang/test/Driver/warn-fsyntax-only.c b/clang/test/Driver/warn-fsyntax-only.c index d13bab41c047ad..dac6742650447f 100644 --- a/clang/test/Driver/warn-fsyntax-only.c +++ b/clang/test/Driver/warn-fsyntax-only.c @@ -1,7 +1,14 @@ // RUN: %clang --target=x86_64 -fsyntax-only -E %s 2>&1 | FileCheck %s --check-prefix=CHECK-PP // RUN: %clang --target=x86_64 -fsyntax-only -S %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASM // RUN: %clang --target=x86_64 -fsyntax-only -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-OBJ +// RUN: %clang --target=x86_64 -fsyntax-only -S -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ASM,CHECK-OBJ // CHECK-PP: warning: argument unused during compilation: '-fsyntax-only' [-Wunused-command-line-argument] // CHECK-ASM: warning: argument unused during compilation: '-S' [-Wunused-command-line-argument] // CHECK-OBJ: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument] + +/// Test that -S and -c don't result in a warning, without -fsyntax-only. +// RUN: %clang -S -c %s -### 2>&1 | FileCheck %s --check-prefix=NO-SYNTAX-ONLY --implicit-check-not=warning +// NO-SYNTAX-ONLY: "-cc1" +// NO-SYNTAX-ONLY-SAME: "-S" +// NO-SYNTAX-ONLY-SAME: "c" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits