Extended list of valid frontend options with '-cl-std=CL2.0'.
authorAnastasia Stulova <anastasia.stulova@arm.com>
Thu, 20 Nov 2014 19:25:00 +0000 (19:25 +0000)
committerAnastasia Stulova <anastasia.stulova@arm.com>
Thu, 20 Nov 2014 19:25:00 +0000 (19:25 +0000)
This option sets language mode for the compilation of a source file to be OpenCL v2.0.

Example: clang -cc1 -cl-std=CL2.0 myfile.cl
llvm-svn: 222444

clang/include/clang/Frontend/LangStandards.def
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Frontend/std.cl [new file with mode: 0644]

index 5bcabaa..cac9c3c 100644 (file)
@@ -141,6 +141,9 @@ LANGSTANDARD(opencl11, "CL1.1",
 LANGSTANDARD(opencl12, "CL1.2",
              "OpenCL 1.2",
              LineComment | C99 | Digraphs | HexFloat)
+LANGSTANDARD(opencl20, "CL2.0",
+             "OpenCL 2.0",
+             LineComment | C99 | Digraphs | HexFloat)
 
 // CUDA
 LANGSTANDARD(cuda, "cuda",
index a57c8b5..f261c6c 100644 (file)
@@ -1172,10 +1172,12 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
   if (LangStd == LangStandard::lang_opencl)
     Opts.OpenCLVersion = 100;
   else if (LangStd == LangStandard::lang_opencl11)
-      Opts.OpenCLVersion = 110;
+    Opts.OpenCLVersion = 110;
   else if (LangStd == LangStandard::lang_opencl12)
     Opts.OpenCLVersion = 120;
-  
+  else if (LangStd == LangStandard::lang_opencl20)
+    Opts.OpenCLVersion = 200;
+
   // OpenCL has some additional defaults.
   if (Opts.OpenCL) {
     Opts.AltiVec = 0;
@@ -1323,6 +1325,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
     .Case("CL", LangStandard::lang_opencl)
     .Case("CL1.1", LangStandard::lang_opencl11)
     .Case("CL1.2", LangStandard::lang_opencl12)
+    .Case("CL2.0", LangStandard::lang_opencl20)
     .Default(LangStandard::lang_unspecified);
     
     if (OpenCLLangStd == LangStandard::lang_unspecified) {
diff --git a/clang/test/Frontend/std.cl b/clang/test/Frontend/std.cl
new file mode 100644 (file)
index 0000000..b811b64
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.2
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL2.0
+// RUN: not %clang_cc1 %s -fsyntax-only -cl-std=invalid -DINVALID 2>&1 | FileCheck %s
+
+#ifdef INVALID 
+// CHECK: invalid value 'invalid' in '-cl-std=invalid'
+#endif