[PATCH] D47613: Mark __c11_atomic_load as const

JF Bastien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 31 16:39:19 PDT 2018


jfb created this revision.
jfb added reviewers: EricWF, mclow.lists.
Herald added subscribers: cfe-commits, christof.

C++11 onwards specs the non-member functions atomic_load and atomic_load_explicit as taking the atomic<T> by const (potentially volatile) pointer. C11, in its infinite wisdom, decided to drop the const, and C17 will fix this with DR459 (the current draft forgot to fix B.16, but that’s not the normative part).

This patch fixes the libc++ version of the __c11_atomic_load builtins defined for GCC's compatibility sake.

Discussion: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058129.html

rdar://problem/27426936


Repository:
  rCXX libc++

https://reviews.llvm.org/D47613

Files:
  include/atomic


Index: include/atomic
===================================================================
--- include/atomic
+++ include/atomic
@@ -698,16 +698,16 @@
 }
 
 template <typename _Tp>
-static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a,
+static inline _Tp __c11_atomic_load(const volatile _Atomic(_Tp)* __a,
                                     memory_order __order) {
   _Tp __ret;
   __atomic_load(&__a->__a_value, &__ret,
                 __gcc_atomic::__to_gcc_order(__order));
   return __ret;
 }
 
 template <typename _Tp>
-static inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) {
+static inline _Tp __c11_atomic_load(const _Atomic(_Tp)* __a, memory_order __order) {
   _Tp __ret;
   __atomic_load(&__a->__a_value, &__ret,
                 __gcc_atomic::__to_gcc_order(__order));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47613.149381.patch
Type: text/x-patch
Size: 816 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180531/5e46954e/attachment.bin>


More information about the cfe-commits mailing list