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) {
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;
--- /dev/null
+// 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
-// 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