<div dir="ltr"><p dir="ltr">On 25 May 2016 9:13 a.m., "Yaxun Liu via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
> yaxunl created this revision.<br>
> yaxunl added a reviewer: Anastasia.<br>
> yaxunl added subscribers: pxli168, bader, tstellarAMD, cfe-commits.<br>
><br>
> Fix a regression which forbids using -std=CL|CL1.1|CL1.2|CL2.0 in driver.<br>
><br>
> Changed -std=cl to -std=CL to match -cl-std=CL.</p><p>This is inconsistent with our existing command-line interface. It would be more consistent to change -cl-std= to accept lowercase cl instead.</p><p dir="ltr">
> <a href="http://reviews.llvm.org/D20630" target="_blank">http://reviews.llvm.org/D20630</a><br>
><br>
> Files:<br>
> include/clang/Frontend/LangStandards.def<br>
> lib/Frontend/CompilerInvocation.cpp<br>
> test/Driver/<a href="http://opencl.cl" target="_blank">opencl.cl</a><br>
><br>
> Index: test/Driver/<a href="http://opencl.cl" target="_blank">opencl.cl</a><br>
> ===================================================================<br>
> --- /dev/null<br>
> +++ test/Driver/<a href="http://opencl.cl" target="_blank">opencl.cl</a><br>
> @@ -0,0 +1,11 @@<br>
> +// RUN: %clang %s<br>
> +// RUN: %clang -std=CL %s<br>
> +// RUN: %clang -std=CL1.1 %s<br>
> +// RUN: %clang -std=CL1.2 %s<br>
> +// RUN: %clang -std=CL2.0 %s<br>
> +// RUN: not %clang_cc1 -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s<br>
> +// RUN: not %clang_cc1 -std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s<br>
> +// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'<br>
> +// CHECK-INVALID: error: invalid value 'invalid' in '-std=invalid'<br>
> +<br>
> +kernel void func(void);<br>
> Index: lib/Frontend/CompilerInvocation.cpp<br>
> ===================================================================<br>
> --- lib/Frontend/CompilerInvocation.cpp<br>
> +++ lib/Frontend/CompilerInvocation.cpp<br>
> @@ -1398,6 +1398,13 @@<br>
> Opts.AddVFSOverlayFile(A->getValue());<br>
> }<br>
><br>
> +bool isOpenCL(LangStandard::Kind LangStd) {<br>
> + return LangStd == LangStandard::lang_opencl<br>
> + || LangStd == LangStandard::lang_opencl11<br>
> + || LangStd == LangStandard::lang_opencl12<br>
> + || LangStd == LangStandard::lang_opencl20;<br>
> +}<br>
> +<br>
> void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,<br>
> const llvm::Triple &T,<br>
> LangStandard::Kind LangStd) {<br>
> @@ -1462,7 +1469,7 @@<br>
> Opts.ImplicitInt = Std.hasImplicitInt();<br>
><br>
> // Set OpenCL Version.<br>
> - Opts.OpenCL = LangStd == LangStandard::lang_opencl || IK == IK_OpenCL;<br>
> + Opts.OpenCL = isOpenCL(LangStd) || IK == IK_OpenCL;<br>
> if (LangStd == LangStandard::lang_opencl)<br>
> Opts.OpenCLVersion = 100;<br>
> else if (LangStd == LangStandard::lang_opencl11)<br>
> @@ -1555,8 +1562,9 @@<br>
> << A->getAsString(Args) << "C++/ObjC++";<br>
> break;<br>
> case IK_OpenCL:<br>
> - Diags.Report(diag::err_drv_argument_not_allowed_with)<br>
> - << A->getAsString(Args) << "OpenCL";<br>
> + if (!isOpenCL(LangStd))<br>
> + Diags.Report(diag::err_drv_argument_not_allowed_with)<br>
> + << A->getAsString(Args) << "OpenCL";<br>
> break;<br>
> case IK_CUDA:<br>
> case IK_PreprocessedCuda:<br>
> Index: include/clang/Frontend/LangStandards.def<br>
> ===================================================================<br>
> --- include/clang/Frontend/LangStandards.def<br>
> +++ include/clang/Frontend/LangStandards.def<br>
> @@ -132,7 +132,7 @@<br>
> Digraphs | HexFloat | GNUMode)<br>
><br>
> // OpenCL<br>
> -LANGSTANDARD(opencl, "cl",<br>
> +LANGSTANDARD(opencl, "CL",<br>
> "OpenCL 1.0",<br>
> LineComment | C99 | Digraphs | HexFloat)<br>
> LANGSTANDARD(opencl11, "CL1.1",<br>
><br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
></p>
</div>