From 6cd4b473d1cc4cfc4d7ba4ed6260afbc013e970a Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 18 Apr 2016 23:12:59 +0000 Subject: [PATCH] Mark -Xclang as being a compilation-only option so that the clang driver doesn't warn if it's passed to a link action. This matches the behavior for most other compilation-only options (including things like -f flags), and is necessary to suppress warnings on systems like cmake that always pass all compile flags to the linker. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266695 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 2 +- test/Driver/linker-opts.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 1a8c7c606d..a28518e8c6 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -337,7 +337,7 @@ def Xassembler : Separate<["-"], "Xassembler">, HelpText<"Pass to the assembler">, MetaVarName<"">; def Xclang : Separate<["-"], "Xclang">, HelpText<"Pass to the clang compiler">, MetaVarName<"">, - Flags<[DriverOption, CoreOption]>; + Flags<[DriverOption, CoreOption]>, Group; def Xcuda_fatbinary : Separate<["-"], "Xcuda-fatbinary">, HelpText<"Pass to fatbinary invocation">, MetaVarName<"">; def Xcuda_ptxas : Separate<["-"], "Xcuda-ptxas">, diff --git a/test/Driver/linker-opts.c b/test/Driver/linker-opts.c index 24866a63b1..29ef136c8b 100644 --- a/test/Driver/linker-opts.c +++ b/test/Driver/linker-opts.c @@ -1,3 +1,6 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// // RUN: env LIBRARY_PATH=%T/test1 %clang -x c %s -### 2>&1 | FileCheck %s // CHECK: "-L{{.*}}/test1" @@ -9,3 +12,12 @@ // Make sure that LIBRARY_PATH works for both i386 and x86_64 on Darwin. // RUN: env LIBRARY_PATH=%T/test1 %clang -target x86_64-apple-darwin %s -### 2>&1 | FileCheck %s // RUN: env LIBRARY_PATH=%T/test1 %clang -target i386-apple-darwin %s -### 2>&1 | FileCheck %s +// +// Make sure that we don't warn on unused compiler arguments. +// RUN: %clang -Xclang -I. -x c %s -c -o %t/tmp.o +// RUN: %clang -Xclang -I. %t/tmp.o -o %t/tmp -### 2>&1 | FileCheck %s --check-prefix=NO-UNUSED +// NO-UNUSED-NOT: warning:{{.*}}unused +// +// Make sure that we do warn in other cases. +// RUN: %clang %s -lfoo -c -o %t/tmp2.o -### 2>&1 | FileCheck %s --check-prefix=UNUSED +// UNUSED: warning:{{.*}}unused -- 2.40.0