[PATCH] D20630: [OpenCL] Allow -std=CL|CL1.1|CL1.2|CL2.0 in driver
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Wed May 25 09:13:19 PDT 2016
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.
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",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20630.58436.patch
Type: text/x-patch
Size: 2614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160525/41b30a19/attachment.bin>
More information about the cfe-commits
mailing list