[PATCH] D20630: [OpenCL] Allow -std=CL|CL1.1|CL1.2|CL2.0 in driver

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed May 25 11:53:35 PDT 2016


On 25 May 2016 9:13 a.m., "Yaxun Liu via cfe-commits" <
cfe-commits at lists.llvm.org> wrote:
>
> yaxunl created this revision.
> yaxunl added a reviewer: Anastasia.
> yaxunl added subscribers: pxli168, bader, tstellarAMD, cfe-commits.
>
> Fix a regression which forbids using -std=CL|CL1.1|CL1.2|CL2.0 in driver.
>
> Changed -std=cl to -std=CL to match -cl-std=CL.

This is inconsistent with our existing command-line interface. It would be
more consistent to change -cl-std= to accept lowercase cl instead.

> http://reviews.llvm.org/D20630
>
> Files:
>   include/clang/Frontend/LangStandards.def
>   lib/Frontend/CompilerInvocation.cpp
>   test/Driver/opencl.cl
>
> 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);
> 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: 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",
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160525/60ad0578/attachment.html>


More information about the cfe-commits mailing list