[Libclc-dev] [PATCH 1/1] Avoid ambiguity in calling atom_add functions.

Jan Vesely via Libclc-dev libclc-dev at lists.llvm.org
Wed Sep 7 07:55:15 PDT 2016


clang (since r280553) allows pointer casts in function overloads,
so we need to disambiguate the second argument.

clang might be smarter about overloads in the future
(see https://reviews.llvm.org/D24113), but let's be safe in libclc anyway.

Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
 generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl | 2 +-
 generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl | 2 +-
 generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl  | 2 +-
 generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl b/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
index a74158d..cc24d2f 100644
--- a/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
+++ b/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
@@ -2,7 +2,7 @@
 
 #define IMPL(TYPE) \
 _CLC_OVERLOAD _CLC_DEF TYPE atom_dec(global TYPE *p) { \
-  return atom_sub(p, 1); \
+  return atom_sub(p, (TYPE)1); \
 }
 
 IMPL(int)
diff --git a/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl b/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
index 1404b5a..9193ae3 100644
--- a/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
+++ b/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
@@ -2,7 +2,7 @@
 
 #define IMPL(TYPE) \
 _CLC_OVERLOAD _CLC_DEF TYPE atom_inc(global TYPE *p) { \
-  return atom_add(p, 1); \
+  return atom_add(p, (TYPE)1); \
 }
 
 IMPL(int)
diff --git a/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl b/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
index d22c333..cfb3d80 100644
--- a/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
+++ b/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
@@ -2,7 +2,7 @@
 
 #define IMPL(TYPE) \
 _CLC_OVERLOAD _CLC_DEF TYPE atom_dec(local TYPE *p) { \
-  return atom_sub(p, 1); \
+  return atom_sub(p, (TYPE)1); \
 }
 
 IMPL(int)
diff --git a/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl b/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
index 4ba0d06..8ea4738 100644
--- a/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
+++ b/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
@@ -2,7 +2,7 @@
 
 #define IMPL(TYPE) \
 _CLC_OVERLOAD _CLC_DEF TYPE atom_inc(local TYPE *p) { \
-  return atom_add(p, 1); \
+  return atom_add(p, (TYPE)1); \
 }
 
 IMPL(int)
-- 
2.7.4



More information about the Libclc-dev mailing list