[cfe-commits] r125588 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaType.cpp test/CMakeLists.txt test/SemaOpenCL/ test/SemaOpenCL/extension-fp64.cl
Peter Collingbourne
peter at pcc.me.uk
Tue Feb 15 11:46:23 PST 2011
Author: pcc
Date: Tue Feb 15 13:46:23 2011
New Revision: 125588
URL: http://llvm.org/viewvc/llvm-project?rev=125588&view=rev
Log:
OpenCL: semantic analysis support for cl_khr_fp64 extension
Added:
cfe/trunk/test/SemaOpenCL/
cfe/trunk/test/SemaOpenCL/extension-fp64.cl
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CMakeLists.txt
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=125588&r1=125587&r2=125588&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Feb 15 13:46:23 2011
@@ -3635,6 +3635,8 @@
"use of C99-specific array features, accepted as an extension">;
def err_c99_array_usage_cxx : Error<
"C99-specific array features are not permitted in C++">;
+def err_double_requires_fp64 : Error<
+ "use of type 'double' requires cl_khr_fp64 extension to be enabled">;
def note_getter_unavailable : Note<
"or because setter is declared here, but no getter method %0 is found">;
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=125588&r1=125587&r2=125588&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Feb 15 13:46:23 2011
@@ -671,6 +671,11 @@
Result = Context.LongDoubleTy;
else
Result = Context.DoubleTy;
+
+ if (S.getLangOptions().OpenCL && !S.getOpenCLOptions().cl_khr_fp64) {
+ S.Diag(DS.getTypeSpecTypeLoc(), diag::err_double_requires_fp64);
+ declarator.setInvalidType(true);
+ }
break;
case DeclSpec::TST_bool: Result = Context.BoolTy; break; // _Bool or bool
case DeclSpec::TST_decimal32: // _Decimal32
Modified: cfe/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=125588&r1=125587&r2=125588&view=diff
==============================================================================
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Tue Feb 15 13:46:23 2011
@@ -23,6 +23,7 @@
"SemaCXX"
"SemaObjC"
"SemaObjCXX"
+ "SemaOpenCL"
"SemaTemplate")
set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}")
Added: cfe/trunk/test/SemaOpenCL/extension-fp64.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extension-fp64.cl?rev=125588&view=auto
==============================================================================
--- cfe/trunk/test/SemaOpenCL/extension-fp64.cl (added)
+++ cfe/trunk/test/SemaOpenCL/extension-fp64.cl Tue Feb 15 13:46:23 2011
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+void f1(double da) { // expected-error {{requires cl_khr_fp64 extension}}
+ double d; // expected-error {{requires cl_khr_fp64 extension}}
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+void f2(void) {
+ double d;
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : disable
+
+void f3(void) {
+ double d; // expected-error {{requires cl_khr_fp64 extension}}
+}
More information about the cfe-commits
mailing list