summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/sequences/array/empty.fail.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2017-11-15 05:51:26 +0000
committerMarshall Clow <mclow.lists@gmail.com>2017-11-15 05:51:26 +0000
commit72c8fad4270a9810e7868892910b8029e8a92b1c (patch)
treea74afdae3cd83274231149fa36dd5b33194bbda7 /libcxx/test/std/containers/sequences/array/empty.fail.cpp
parent260ad71dfee02ba2cc49541de8f70c9b897bb4a5 (diff)
downloadbcm5719-llvm-72c8fad4270a9810e7868892910b8029e8a92b1c.tar.gz
bcm5719-llvm-72c8fad4270a9810e7868892910b8029e8a92b1c.zip
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
llvm-svn: 318269
Diffstat (limited to 'libcxx/test/std/containers/sequences/array/empty.fail.cpp')
-rw-r--r--libcxx/test/std/containers/sequences/array/empty.fail.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/sequences/array/empty.fail.cpp b/libcxx/test/std/containers/sequences/array/empty.fail.cpp
new file mode 100644
index 00000000000..85bf5a7c9da
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/empty.fail.cpp
@@ -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}}
+}
OpenPOWER on IntegriCloud