r209824 - No longer allow the -std options to entirely override the -x language option. This allows -x cuda -std=c++11, for instance.
Aaron Ballman
aaron at aaronballman.com
Thu May 29 09:39:42 PDT 2014
Author: aaronballman
Date: Thu May 29 11:39:42 2014
New Revision: 209824
URL: http://llvm.org/viewvc/llvm-project?rev=209824&view=rev
Log:
No longer allow the -std options to entirely override the -x language option. This allows -x cuda -std=c++11, for instance.
Added:
cfe/trunk/test/Frontend/stdlang.c
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Index/attributes-cuda.cu
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=209824&r1=209823&r2=209824&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu May 29 11:39:42 2014
@@ -1114,18 +1114,13 @@ void CompilerInvocation::setLangDefaults
Opts.ImplicitInt = Std.hasImplicitInt();
// Set OpenCL Version.
- if (LangStd == LangStandard::lang_opencl) {
- Opts.OpenCL = 1;
+ Opts.OpenCL = LangStd == LangStandard::lang_opencl || IK == IK_OpenCL;
+ if (LangStd == LangStandard::lang_opencl)
Opts.OpenCLVersion = 100;
- }
- else if (LangStd == LangStandard::lang_opencl11) {
- Opts.OpenCL = 1;
+ else if (LangStd == LangStandard::lang_opencl11)
Opts.OpenCLVersion = 110;
- }
- else if (LangStd == LangStandard::lang_opencl12) {
- Opts.OpenCL = 1;
+ else if (LangStd == LangStandard::lang_opencl12)
Opts.OpenCLVersion = 120;
- }
// OpenCL has some additional defaults.
if (Opts.OpenCL) {
@@ -1136,8 +1131,7 @@ void CompilerInvocation::setLangDefaults
Opts.NativeHalfType = 1;
}
- if (LangStd == LangStandard::lang_cuda)
- Opts.CUDA = 1;
+ Opts.CUDA = LangStd == LangStandard::lang_cuda || IK == IK_CUDA;
// OpenCL and C++ both have bool, true, false keywords.
Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
Added: cfe/trunk/test/Frontend/stdlang.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/stdlang.c?rev=209824&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/stdlang.c (added)
+++ cfe/trunk/test/Frontend/stdlang.c Thu May 29 11:39:42 2014
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
+// RUN: %clang_cc1 -x cl -std=c99 -DOPENCL %s
+// expected-no-diagnostics
+
+#if defined(CUDA)
+ __attribute__((device)) void f_device();
+#elif defined(OPENCL)
+ kernel void func(void);
+#endif
Modified: cfe/trunk/test/Index/attributes-cuda.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/attributes-cuda.cu?rev=209824&r1=209823&r2=209824&view=diff
==============================================================================
--- cfe/trunk/test/Index/attributes-cuda.cu (original)
+++ cfe/trunk/test/Index/attributes-cuda.cu Thu May 29 11:39:42 2014
@@ -1,11 +1,10 @@
-// RUN: c-index-test -test-load-source all -x cuda -std=cuda %s | FileCheck %s
+// RUN: c-index-test -test-load-source all -x cuda %s | FileCheck %s
__attribute__((device)) void f_device();
__attribute__((global)) void f_global();
__attribute__((constant)) int* g_constant;
__attribute__((host)) void f_host();
-
// CHECK: attributes-cuda.cu:3:30: FunctionDecl=f_device:3:30
// CHECK-NEXT: attributes-cuda.cu:3:16: attribute(device)
// CHECK: attributes-cuda.cu:4:30: FunctionDecl=f_global:4:30
More information about the cfe-commits
mailing list