]> granicus.if.org Git - clang/commitdiff
Silence unused argument warning for --cuda-host-only.
authorArtem Belevich <tra@google.com>
Tue, 28 Jul 2015 21:01:30 +0000 (21:01 +0000)
committerArtem Belevich <tra@google.com>
Tue, 28 Jul 2015 21:01:30 +0000 (21:01 +0000)
Differential Revision: http://reviews.llvm.org/D11575

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243479 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Driver.cpp
test/Driver/cuda-options.cu

index 86cf8556ef20a86421afdf8d65729ca9a50b656e..a39f7fc678f80aaa5844f936ac78d38485b97f08 100644 (file)
@@ -1490,6 +1490,10 @@ void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args,
 
   // Claim ignored clang-cl options.
   Args.ClaimAllArgs(options::OPT_cl_ignored_Group);
+
+  // Claim --cuda-host-only arg which may be passed to non-CUDA
+  // compilations and should not trigger warnings there.
+  Args.ClaimAllArgs(options::OPT_cuda_host_only);
 }
 
 std::unique_ptr<Action>
index 37411680b61c31aa5a0a78a771395f63119b2812..d1575db727ba635da5d3d3e281164e65cc6a9291 100644 (file)
 // Make sure we don't link anything.
 // RUN:   -check-prefix CUDA-NL %s
 
+// --cuda-host-only should never trigger unused arg warning.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
+// RUN:    FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
+// RUN:    FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
+
+// --cuda-device-only should not produce warning compiling CUDA files
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
+// RUN:    FileCheck -check-prefix CUDA-NO-UNUSED-CDO %s
+
+// --cuda-device-only should warn during non-CUDA compilation.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
+// RUN:    FileCheck -check-prefix CUDA-UNUSED-CDO %s
+
 // Match device-side compilation
 // CUDA-D1: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
 // CUDA-D1-SAME: "-fcuda-is-device"
 
 // Match no linker
 // CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
+
+// CUDA-NO-UNUSED-CHO-NOT: warning: argument unused during compilation: '--cuda-host-only'
+// CUDA-UNUSED-CDO: warning: argument unused during compilation: '--cuda-device-only'
+// CUDA-NO-UNUSED-CDO-NOT: warning: argument unused during compilation: '--cuda-device-only'