]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/gcc-tumbl.git/commitdiff
PR libstdc++/56012
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Feb 2013 00:57:36 +0000 (00:57 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Feb 2013 00:57:36 +0000 (00:57 +0000)
* include/bits/atomic_base.h (atomic_flag): Fix narrowing conversion.
* testsuite/29_atomics/atomic/operators/56012.cc: New.

PR libstdc++/56011
* include/std/atomic (atomic<bool>::operator=(bool) volatile): Add
missing overload.
* testsuite/29_atomics/atomic/operators/56011.cc: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@196301 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/atomic_base.h
libstdc++-v3/include/std/atomic
libstdc++-v3/testsuite/29_atomics/atomic/operators/56011.cc [new file with mode: 0644]
libstdc++-v3/testsuite/29_atomics/atomic_flag/cons/56012.cc [new file with mode: 0644]

index cd4e0861d24ef5bf12a18ab8ee7d11e5348f1d5a..f97792722cf99910d9b6b94758bd54f1d079b9c3 100644 (file)
@@ -1,3 +1,14 @@
+2013-02-26  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       PR libstdc++/56012
+       * include/bits/atomic_base.h (atomic_flag): Fix narrowing conversion.
+       * testsuite/29_atomics/atomic/operators/56012.cc: New.
+
+       PR libstdc++/56011
+       * include/std/atomic (atomic<bool>::operator=(bool) volatile): Add
+       missing overload.
+       * testsuite/29_atomics/atomic/operators/56011.cc: New.
+
 2013-02-20  Jonathan Wakely  <jwakely.gcc@gmail.com>
 
        * include/std/streambuf (basic_streambuf): Fix unclosed Doxygen group.
index bd14e35cd5af54866e9e8a8f5ac5e744b140ea64..191db7b5f01cce2bc0e6d1c893161e20268f9fe1 100644 (file)
@@ -212,6 +212,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct atomic<_Tp*>;
 
+    /* The target's "set" value for test-and-set may not be exactly 1.  */
+#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1
+    typedef bool __atomic_flag_data_type;
+#else
+    typedef unsigned char __atomic_flag_data_type;
+#endif
 
   /**
    *  @brief Base type for atomic_flag.
@@ -227,12 +233,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   struct __atomic_flag_base
   {
-    /* The target's "set" value for test-and-set may not be exactly 1.  */
-#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1
-    bool _M_i;
-#else
-    unsigned char _M_i;
-#endif
+    __atomic_flag_data_type _M_i;
   };
 
   _GLIBCXX_END_EXTERN_C
@@ -250,7 +251,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     // Conversion to ATOMIC_FLAG_INIT.
     constexpr atomic_flag(bool __i) noexcept
-      : __atomic_flag_base({ __i ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0 })
+      : __atomic_flag_base{ _S_init(__i) }
     { }
 
     bool
@@ -284,6 +285,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       __atomic_clear (&_M_i, __m);
     }
+
+  private:
+    static constexpr __atomic_flag_data_type
+    _S_init(bool __i)
+    { return __i ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0; }
   };
 
 
index 31673e96a7c000944672ea46e240f6cee28ba44c..a2f8058c8955d7ab30c9f0be98c06806cf89a73d 100644 (file)
@@ -69,6 +69,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     operator=(bool __i) noexcept
     { return _M_base.operator=(__i); }
 
+    bool
+    operator=(bool __i) volatile noexcept
+    { return _M_base.operator=(__i); }
+
     operator bool() const noexcept
     { return _M_base.load(); }
 
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/operators/56011.cc b/libstdc++-v3/testsuite/29_atomics/atomic/operators/56011.cc
new file mode 100644 (file)
index 0000000..1d77a55
--- /dev/null
@@ -0,0 +1,29 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <atomic>
+void test01()
+{
+  using namespace std;
+  volatile atomic<bool> ab1 __attribute__((unused));
+  ab1 = true;
+  volatile atomic_bool ab2 __attribute__((unused));
+  ab2 = true;
+}
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/cons/56012.cc b/libstdc++-v3/testsuite/29_atomics/atomic_flag/cons/56012.cc
new file mode 100644 (file)
index 0000000..64f3b97
--- /dev/null
@@ -0,0 +1,26 @@
+// { dg-options "-std=gnu++0x -Wsystem-headers -Wnarrowing" }
+// { dg-do compile }
+
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <atomic>
+void test01()
+{
+  using namespace std;
+  atomic_flag af __attribute__((unused)) = ATOMIC_FLAG_INIT;
+}