[libcxx] r318269 - First part of P0600 - '[[nodiscard] in the standard library'. Mark the 'empty()' methods of all the containers as nodiscard. If you're calling empty() w/o looking at the result, you probably meanto to call 'clear()'. c++2a only

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 14 21:51:26 PST 2017


Author: marshall
Date: Tue Nov 14 21:51:26 2017
New Revision: 318269

URL: http://llvm.org/viewvc/llvm-project?rev=318269&view=rev
Log:
First part of P0600 - '[[nodiscard] in the standard library'. Mark the 'empty()' methods of all the containers as nodiscard. If you're calling empty() w/o looking at the result, you probably meanto to call 'clear()'. c++2a only

Added:
    libcxx/trunk/test/std/containers/associative/map/map.access/empty.fail.cpp
    libcxx/trunk/test/std/containers/associative/multimap/empty.fail.cpp
    libcxx/trunk/test/std/containers/associative/multiset/empty.fail.cpp
    libcxx/trunk/test/std/containers/associative/set/empty.fail.cpp
    libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.fail.cpp
    libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/empty.fail.cpp
    libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/empty.fail.cpp
    libcxx/trunk/test/std/containers/sequences/array/empty.fail.cpp
    libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.fail.cpp
    libcxx/trunk/test/std/containers/sequences/forwardlist/empty.fail.cpp
    libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.fail.cpp
    libcxx/trunk/test/std/containers/sequences/vector.bool/empty.fail.cpp
    libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.fail.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/empty.fail.cpp
    libcxx/trunk/test/std/containers/unord/unord.multimap/empty.fail.cpp
    libcxx/trunk/test/std/containers/unord/unord.multiset/empty.fail.cpp
    libcxx/trunk/test/std/containers/unord/unord.set/empty.fail.cpp
Modified:
    libcxx/trunk/include/array
    libcxx/trunk/include/deque
    libcxx/trunk/include/forward_list
    libcxx/trunk/include/list
    libcxx/trunk/include/map
    libcxx/trunk/include/queue
    libcxx/trunk/include/set
    libcxx/trunk/include/stack
    libcxx/trunk/include/unordered_map
    libcxx/trunk/include/unordered_set
    libcxx/trunk/include/vector

Modified: libcxx/trunk/include/array
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Tue Nov 14 21:51:26 2017
@@ -183,7 +183,7 @@ struct _LIBCPP_TEMPLATE_VIS array
     _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
     _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
 
     // element access:

Modified: libcxx/trunk/include/deque
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/deque (original)
+++ libcxx/trunk/include/deque Tue Nov 14 21:51:26 2017
@@ -1314,7 +1314,7 @@ public:
     void resize(size_type __n);
     void resize(size_type __n, const value_type& __v);
     void shrink_to_fit() _NOEXCEPT;
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool empty() const _NOEXCEPT {return __base::size() == 0;}
 
     // element access:

Modified: libcxx/trunk/include/forward_list
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/forward_list?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/forward_list (original)
+++ libcxx/trunk/include/forward_list Tue Nov 14 21:51:26 2017
@@ -728,7 +728,7 @@ public:
     const_iterator cbefore_begin() const _NOEXCEPT
         {return const_iterator(base::__before_begin());}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool empty() const _NOEXCEPT
         {return base::__before_begin()->__next_ == nullptr;}
     _LIBCPP_INLINE_VISIBILITY

Modified: libcxx/trunk/include/list
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/list?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/list (original)
+++ libcxx/trunk/include/list Tue Nov 14 21:51:26 2017
@@ -896,7 +896,7 @@ public:
 
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT     {return base::__sz();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool empty() const _NOEXCEPT         {return base::empty();}
     _LIBCPP_INLINE_VISIBILITY
     size_type max_size() const _NOEXCEPT

Modified: libcxx/trunk/include/map
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/map (original)
+++ libcxx/trunk/include/map Tue Nov 14 21:51:26 2017
@@ -1012,7 +1012,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     const_reverse_iterator crend() const _NOEXCEPT {return rend();}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool      empty() const _NOEXCEPT {return __tree_.size() == 0;}
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT {return __tree_.size();}
@@ -1669,7 +1669,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     const_reverse_iterator crend() const _NOEXCEPT {return rend();}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT {return __tree_.size();}

Modified: libcxx/trunk/include/queue
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/queue?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/queue (original)
+++ libcxx/trunk/include/queue Tue Nov 14 21:51:26 2017
@@ -268,7 +268,7 @@ public:
 
 #endif  // _LIBCPP_CXX03_LANG
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool      empty() const {return c.empty();}
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const  {return c.size();}
@@ -490,7 +490,7 @@ public:
                                                          _Alloc>::value>::type* = 0);
 #endif  // _LIBCPP_CXX03_LANG
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool            empty() const {return c.empty();}
     _LIBCPP_INLINE_VISIBILITY
     size_type       size() const  {return c.size();}

Modified: libcxx/trunk/include/set
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/set?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/set (original)
+++ libcxx/trunk/include/set Tue Nov 14 21:51:26 2017
@@ -575,7 +575,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     const_reverse_iterator crend() const _NOEXCEPT {return rend();}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT {return __tree_.size();}
@@ -984,7 +984,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     const_reverse_iterator crend() const _NOEXCEPT {return rend();}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT {return __tree_.size();}

Modified: libcxx/trunk/include/stack
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stack?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/stack (original)
+++ libcxx/trunk/include/stack Tue Nov 14 21:51:26 2017
@@ -181,7 +181,7 @@ public:
             : c(_VSTD::move(__s.c), __a) {}
 #endif  // _LIBCPP_CXX03_LANG
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool empty()     const      {return c.empty();}
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const      {return c.size();}

Modified: libcxx/trunk/include/unordered_map
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_map?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/unordered_map (original)
+++ libcxx/trunk/include/unordered_map Tue Nov 14 21:51:26 2017
@@ -885,7 +885,7 @@ public:
     allocator_type get_allocator() const _NOEXCEPT
         {return allocator_type(__table_.__node_alloc());}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT  {return __table_.size();}
@@ -1634,7 +1634,7 @@ public:
     allocator_type get_allocator() const _NOEXCEPT
         {return allocator_type(__table_.__node_alloc());}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT  {return __table_.size();}

Modified: libcxx/trunk/include/unordered_set
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_set?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/unordered_set (original)
+++ libcxx/trunk/include/unordered_set Tue Nov 14 21:51:26 2017
@@ -450,7 +450,7 @@ public:
     allocator_type get_allocator() const _NOEXCEPT
         {return allocator_type(__table_.__node_alloc());}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT  {return __table_.size();}
@@ -968,7 +968,7 @@ public:
     allocator_type get_allocator() const _NOEXCEPT
         {return allocator_type(__table_.__node_alloc());}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT  {return __table_.size();}

Modified: libcxx/trunk/include/vector
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=318269&r1=318268&r2=318269&view=diff
==============================================================================
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Tue Nov 14 21:51:26 2017
@@ -634,7 +634,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     size_type capacity() const _NOEXCEPT
         {return __base::capacity();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool empty() const _NOEXCEPT
         {return this->__begin_ == this->__end_;}
     size_type max_size() const _NOEXCEPT;
@@ -2290,7 +2290,7 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT
         {return __size_;}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool empty() const _NOEXCEPT
         {return __size_ == 0;}
     void reserve(size_type __n);

Added: libcxx/trunk/test/std/containers/associative/map/map.access/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.access/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/map.access/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/associative/map/map.access/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <map>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::map<int, int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/associative/multimap/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multimap/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/associative/multimap/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <map>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::multimap<int, int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/associative/multiset/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multiset/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/associative/multiset/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <set>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::multiset<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/associative/set/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/set/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/associative/set/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/associative/set/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <set>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::set<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// class priority_queue
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <queue>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::priority_queue<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// class queue
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <queue>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::queue<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// class stack
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <stack>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::stack<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/sequences/array/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/array/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// class array
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <array>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::array<int, 1> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/deque/deque.capacity/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// class deque
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <deque>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::deque<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/sequences/forwardlist/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/forwardlist/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/forwardlist/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// class forward_list
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <forward_list>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::forward_list<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/list/list.capacity/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// class list
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <list>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::list<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/sequences/vector.bool/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector.bool/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector.bool/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// class vector
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <vector>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::vector<bool> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.capacity/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// class vector
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <vector>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::vector<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/unord/unord.map/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.map/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// class unordered_map
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <unordered_map>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::unordered_map<int, int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/unord/unord.multimap/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// class unordered_multimap
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <unordered_map>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::unordered_multimap<int, int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/unord/unord.multiset/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multiset/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multiset/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.multiset/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// class unordered_multiset
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <unordered_set>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::unordered_multiset<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

Added: libcxx/trunk/test/std/containers/unord/unord.set/empty.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.set/empty.fail.cpp?rev=318269&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.set/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/containers/unord/unord.set/empty.fail.cpp Tue Nov 14 21:51:26 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// class unordered_set
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
+#include <unordered_set>
+
+#include "test_macros.h"
+
+int main ()
+{
+    std::unordered_set<int> c;
+    c.empty();  // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
+}




More information about the cfe-commits mailing list