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

Vedran Miletić via Libclc-dev libclc-dev at lists.llvm.org
Wed Sep 7 09:17:04 PDT 2016


On 09/07/2016 04:55 PM, Jan Vesely via Libclc-dev wrote:
> 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)
> 

Reviewed-by: Vedran Miletić <vedran at miletic.net>

-- 
Vedran Miletić
vedran.miletic.net


More information about the Libclc-dev mailing list