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:
Aaron Ballman 2014-05-29 16:39:42 +00:00
parent 9c89ff1945
commit a670c20894
3 changed files with 15 additions and 13 deletions

View File

@ -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;

View File

@ -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

View File

@ -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