Index: include/clang/Frontend/LangStandards.def =================================================================== --- include/clang/Frontend/LangStandards.def +++ include/clang/Frontend/LangStandards.def @@ -132,7 +132,7 @@ Digraphs | HexFloat | GNUMode) // OpenCL -LANGSTANDARD(opencl, "cl", +LANGSTANDARD(opencl, "CL", "OpenCL 1.0", LineComment | C99 | Digraphs | HexFloat) LANGSTANDARD(opencl11, "CL1.1", Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -1398,6 +1398,13 @@ Opts.AddVFSOverlayFile(A->getValue()); } +bool isOpenCL(LangStandard::Kind LangStd) { + return LangStd == LangStandard::lang_opencl + || LangStd == LangStandard::lang_opencl11 + || LangStd == LangStandard::lang_opencl12 + || LangStd == LangStandard::lang_opencl20; +} + void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, const llvm::Triple &T, LangStandard::Kind LangStd) { @@ -1462,7 +1469,7 @@ Opts.ImplicitInt = Std.hasImplicitInt(); // Set OpenCL Version. - Opts.OpenCL = LangStd == LangStandard::lang_opencl || IK == IK_OpenCL; + Opts.OpenCL = isOpenCL(LangStd) || IK == IK_OpenCL; if (LangStd == LangStandard::lang_opencl) Opts.OpenCLVersion = 100; else if (LangStd == LangStandard::lang_opencl11) @@ -1555,8 +1562,9 @@ << A->getAsString(Args) << "C++/ObjC++"; break; case IK_OpenCL: - Diags.Report(diag::err_drv_argument_not_allowed_with) - << A->getAsString(Args) << "OpenCL"; + if (!isOpenCL(LangStd)) + Diags.Report(diag::err_drv_argument_not_allowed_with) + << A->getAsString(Args) << "OpenCL"; break; case IK_CUDA: case IK_PreprocessedCuda: Index: test/Driver/opencl.cl =================================================================== --- /dev/null +++ test/Driver/opencl.cl @@ -0,0 +1,11 @@ +// RUN: %clang %s +// RUN: %clang -std=CL %s +// RUN: %clang -std=CL1.1 %s +// RUN: %clang -std=CL1.2 %s +// RUN: %clang -std=CL2.0 %s +// RUN: not %clang_cc1 -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s +// RUN: not %clang_cc1 -std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s +// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL' +// CHECK-INVALID: error: invalid value 'invalid' in '-std=invalid' + +kernel void func(void);