forked from OSchip/llvm-project
No longer allow the -std options to entirely override the -x language option. This allows -x cuda -std=c++11, for instance.
llvm-svn: 209824
This commit is contained in:
parent
9c89ff1945
commit
a670c20894
|
@ -1114,18 +1114,13 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
|
|||
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(LangOptions &Opts, InputKind IK,
|
|||
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;
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue