diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2017-11-15 05:51:26 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2017-11-15 05:51:26 +0000 |
commit | 88626bf496e9a1276652790438b389e65950629f (patch) | |
tree | d975e9769477acff346690e7bfffa48a7ebd4ffc /test/std/containers/associative/map | |
parent | 2645a49a67cd23f82f3a431adeb4488ff7a53d55 (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318269 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/std/containers/associative/map')
-rw-r--r-- | test/std/containers/associative/map/map.access/empty.fail.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/std/containers/associative/map/map.access/empty.fail.cpp b/test/std/containers/associative/map/map.access/empty.fail.cpp new file mode 100644 index 000000000..14ac13c99 --- /dev/null +++ b/test/std/containers/associative/map/map.access/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. +// +//===----------------------------------------------------------------------===// + +// <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}} +} |