Tolerate even more [[nodiscard]] in the STL. Reviewed as https://reviews.llvm.org/D39080

llvm-svn: 318277
This commit is contained in:
Billy Robert O'Neal III 2017-11-15 07:45:07 +00:00
parent 83252766f9
commit 1c240a89ff
35 changed files with 104 additions and 100 deletions

View File

@ -66,7 +66,7 @@ test()
assert(std::search_n(Iter(ic), Iter(ic+sc), 4, 0) == Iter(ic+sc));
// Check that we properly convert the size argument to an integral.
std::search_n(Iter(ic), Iter(ic+sc), UserDefinedIntegral<unsigned>(0), 0);
(void)std::search_n(Iter(ic), Iter(ic+sc), UserDefinedIntegral<unsigned>(0), 0);
}
int main()

View File

@ -142,7 +142,7 @@ test()
count_equal::count = 0;
// Check that we properly convert the size argument to an integral.
std::search_n(Iter(ic), Iter(ic+sc), UserDefinedIntegral<unsigned>(4), 0, count_equal());
(void)std::search_n(Iter(ic), Iter(ic+sc), UserDefinedIntegral<unsigned>(4), 0, count_equal());
count_equal::count = 0;
}

View File

@ -46,7 +46,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
m.at(6);
(void)m.at(6);
assert(false);
}
catch (std::out_of_range&)
@ -79,7 +79,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
m.at(6);
(void)m.at(6);
assert(false);
}
catch (std::out_of_range&)
@ -115,7 +115,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
m.at(6);
(void)m.at(6);
assert(false);
}
catch (std::out_of_range&)
@ -148,7 +148,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
m.at(6);
(void)m.at(6);
assert(false);
}
catch (std::out_of_range&)

View File

@ -72,7 +72,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
c.at(11);
(void)c.at(11);
assert(false);
}
catch (std::out_of_range&)
@ -130,7 +130,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
c.at(11);
(void)c.at(11);
assert(false);
}
catch (std::out_of_range&)

View File

@ -22,7 +22,7 @@ test1()
{
typedef std::ranlux24 E;
E e1(2);
e1();
(void)e1();
E e2(5);
e2 = e1;
assert(e1 == e2);
@ -38,7 +38,7 @@ test2()
{
typedef std::ranlux48 E;
E e1(3);
e1();
(void)e1();
E e2(5);
e2 = e1;
assert(e1 == e2);

View File

@ -22,7 +22,7 @@ test1()
{
typedef std::ranlux24 E;
E e1;
e1();
(void)e1();
E e2 = e1;
assert(e1 == e2);
assert(e1() == e2());
@ -37,7 +37,7 @@ test2()
{
typedef std::ranlux48 E;
E e1;
e1();
(void)e1();
E e2 = e1;
assert(e1 == e2);
assert(e1() == e2());

View File

@ -25,9 +25,9 @@ test1()
assert(e1 == e2);
e1.discard(3);
assert(e1 != e2);
e2();
e2();
e2();
(void)e2();
(void)e2();
(void)e2();
assert(e1 == e2);
}
@ -39,9 +39,9 @@ test2()
assert(e1 == e2);
e1.discard(3);
assert(e1 != e2);
e2();
e2();
e2();
(void)e2();
(void)e2();
(void)e2();
assert(e1 == e2);
}

View File

@ -22,7 +22,7 @@ test1()
{
typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
E e1(2);
e1();
(void)e1();
E e2(5);
e2 = e1;
assert(e1 == e2);
@ -38,7 +38,7 @@ test2()
{
typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
E e1(3);
e1();
(void)e1();
E e2(5);
e2 = e1;
assert(e1 == e2);

View File

@ -22,7 +22,7 @@ test1()
{
typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
E e1;
e1();
(void)e1();
E e2 = e1;
assert(e1 == e2);
assert(e1() == e2());
@ -37,7 +37,7 @@ test2()
{
typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
E e1;
e1();
(void)e1();
E e2 = e1;
assert(e1 == e2);
assert(e1() == e2());

View File

@ -25,9 +25,9 @@ test1()
assert(e1 == e2);
e1.discard(3);
assert(e1 != e2);
e2();
e2();
e2();
(void)e2();
(void)e2();
(void)e2();
assert(e1 == e2);
}
@ -39,9 +39,9 @@ test2()
assert(e1 == e2);
e1.discard(3);
assert(e1 != e2);
e2();
e2();
e2();
(void)e2();
(void)e2();
(void)e2();
assert(e1 == e2);
}

View File

@ -22,7 +22,7 @@ test1()
{
typedef std::knuth_b E;
E e1(2);
e1();
(void)e1();
E e2(5);
e2 = e1;
assert(e1 == e2);

View File

@ -22,7 +22,7 @@ test1()
{
typedef std::knuth_b E;
E e1;
e1();
(void)e1();
E e2 = e1;
assert(e1 == e2);
assert(e1() == e2());

View File

@ -24,8 +24,10 @@ int main()
typedef std::knuth_b Adaptor;
Engine e;
Adaptor a(e);
for (unsigned k = 0; k <= Adaptor::table_size; ++k)
e();
for (unsigned k = 0; k <= Adaptor::table_size; ++k) {
(void)e();
}
assert(a.base() == e);
}
}

View File

@ -25,8 +25,10 @@ int main()
Engine e;
Engine e0 = e;
Adaptor a(std::move(e0));
for (unsigned k = 0; k <= Adaptor::table_size; ++k)
e();
for (unsigned k = 0; k <= Adaptor::table_size; ++k) {
(void)e();
}
assert(a.base() == e);
}
}

View File

@ -25,9 +25,9 @@ test1()
assert(e1 == e2);
e1.discard(3);
assert(e1 != e2);
e2();
e2();
e2();
(void)e2();
(void)e2();
(void)e2();
assert(e1 == e2);
}

View File

@ -38,7 +38,7 @@ int main()
try
{
std::random_device r("/dev/null");
r();
(void)r();
LIBCPP_ASSERT(false);
}
catch (const std::system_error&)

View File

@ -47,13 +47,13 @@ other()
assert(e1 == e2);
e1.discard(1);
assert(e1 != e2);
e2();
(void)e2();
assert(e1 == e2);
e1.discard(3);
assert(e1 != e2);
e2();
e2();
e2();
(void)e2();
(void)e2();
(void)e2();
assert(e1 == e2);
}

View File

@ -24,7 +24,7 @@ test1()
{
typedef std::mt19937 E;
E e1(2);
e1();
(void)e1();
E e2(5);
e2 = e1;
assert(e1 == e2);
@ -40,7 +40,7 @@ test2()
{
typedef std::mt19937_64 E;
E e1(3);
e1();
(void)e1();
E e2(5);
e2 = e1;
assert(e1 == e2);

View File

@ -24,7 +24,7 @@ test1()
{
typedef std::mt19937 E;
E e1;
e1();
(void)e1();
E e2 = e1;
assert(e1 == e2);
assert(e1() == e2());
@ -39,7 +39,7 @@ test2()
{
typedef std::mt19937_64 E;
E e1;
e1();
(void)e1();
E e2(e1);
assert(e1 == e2);
assert(e1() == e2());

View File

@ -28,9 +28,9 @@ test1()
assert(e1 == e2);
e1.discard(3);
assert(e1 != e2);
e2();
e2();
e2();
(void)e2();
(void)e2();
(void)e2();
assert(e1 == e2);
}
@ -42,9 +42,9 @@ test2()
assert(e1 == e2);
e1.discard(3);
assert(e1 != e2);
e2();
e2();
e2();
(void)e2();
(void)e2();
(void)e2();
assert(e1 == e2);
}

View File

@ -22,7 +22,7 @@ test1()
{
typedef std::ranlux24_base E;
E e1(2);
e1();
(void)e1();
E e2(5);
e2 = e1;
assert(e1 == e2);
@ -38,7 +38,7 @@ test2()
{
typedef std::ranlux48_base E;
E e1(3);
e1();
(void)e1();
E e2(5);
e2 = e1;
assert(e1 == e2);

View File

@ -22,7 +22,7 @@ test1()
{
typedef std::ranlux24_base E;
E e1;
e1();
(void)e1();
E e2 = e1;
assert(e1 == e2);
assert(e1() == e2());
@ -37,7 +37,7 @@ test2()
{
typedef std::ranlux48_base E;
E e1;
e1();
(void)e1();
E e2(e1);
assert(e1 == e2);
assert(e1() == e2());

View File

@ -25,9 +25,9 @@ test1()
assert(e1 == e2);
e1.discard(3);
assert(e1 != e2);
e2();
e2();
e2();
(void)e2();
(void)e2();
(void)e2();
assert(e1 == e2);
}
@ -39,9 +39,9 @@ test2()
assert(e1 == e2);
e1.discard(3);
assert(e1 != e2);
e2();
e2();
e2();
(void)e2();
(void)e2();
(void)e2();
assert(e1 == e2);
}

View File

@ -33,7 +33,7 @@ extern "C" void LLVMFuzzerTestOneInput(const char *data)
std::regex::flag_type flag = std::regex_constants::grep;
std::string s((const char *)data, size);
std::regex re(s, flag);
std::regex_match(s, re);
(void)std::regex_match(s, re);
}
catch (std::regex_error &) {}
}

View File

@ -102,7 +102,7 @@ int main()
L2 l1;
try
{
std::try_lock(l0, l1);
(void)std::try_lock(l0, l1);
assert(false);
}
catch (int)
@ -116,7 +116,7 @@ int main()
L0 l1;
try
{
std::try_lock(l0, l1);
(void)std::try_lock(l0, l1);
assert(false);
}
catch (int)
@ -152,7 +152,7 @@ int main()
L2 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -206,7 +206,7 @@ int main()
L2 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -222,7 +222,7 @@ int main()
L0 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -238,7 +238,7 @@ int main()
L0 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -301,7 +301,7 @@ int main()
L1 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -317,7 +317,7 @@ int main()
L0 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -333,7 +333,7 @@ int main()
L2 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -349,7 +349,7 @@ int main()
L2 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -365,7 +365,7 @@ int main()
L1 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -381,7 +381,7 @@ int main()
L2 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -406,7 +406,7 @@ int main()
L1 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -440,7 +440,7 @@ int main()
L1 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)
@ -456,7 +456,7 @@ int main()
L0 l2;
try
{
std::try_lock(l0, l1, l2);
(void)std::try_lock(l0, l1, l2);
assert(false);
}
catch (int)

View File

@ -44,7 +44,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock();
(void)lk.try_lock();
assert(false);
}
catch (std::system_error& e)
@ -60,7 +60,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock();
(void)lk.try_lock();
assert(false);
}
catch (std::system_error& e)

View File

@ -49,7 +49,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock_for(ms(5));
(void)lk.try_lock_for(ms(5));
assert(false);
}
catch (std::system_error& e)
@ -65,7 +65,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock_for(ms(5));
(void)lk.try_lock_for(ms(5));
assert(false);
}
catch (std::system_error& e)

View File

@ -49,7 +49,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock_until(Clock::now());
(void)lk.try_lock_until(Clock::now());
assert(false);
}
catch (std::system_error& e)
@ -65,7 +65,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock_until(Clock::now());
(void)lk.try_lock_until(Clock::now());
assert(false);
}
catch (std::system_error& e)

View File

@ -43,7 +43,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock();
(void)lk.try_lock();
assert(false);
}
catch (std::system_error& e)
@ -59,7 +59,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock();
(void)lk.try_lock();
assert(false);
}
catch (std::system_error& e)

View File

@ -48,7 +48,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock_for(ms(5));
(void)lk.try_lock_for(ms(5));
assert(false);
}
catch (std::system_error& e)
@ -64,7 +64,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock_for(ms(5));
(void)lk.try_lock_for(ms(5));
assert(false);
}
catch (std::system_error& e)

View File

@ -48,7 +48,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock_until(Clock::now());
(void)lk.try_lock_until(Clock::now());
assert(false);
}
catch (std::system_error& e)
@ -64,7 +64,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
lk.try_lock_until(Clock::now());
(void)lk.try_lock_until(Clock::now());
assert(false);
}
catch (std::system_error& e)

View File

@ -80,7 +80,7 @@ void checkThrows(any& a)
{
#if !defined(TEST_HAS_NO_EXCEPTIONS)
try {
any_cast<Type>(a);
(void)any_cast<Type>(a);
assert(false);
} catch (bad_any_cast const &) {
// do nothing
@ -89,7 +89,7 @@ void checkThrows(any& a)
}
try {
any_cast<ConstT>(static_cast<any const&>(a));
(void)any_cast<ConstT>(static_cast<any const&>(a));
assert(false);
} catch (bad_any_cast const &) {
// do nothing
@ -103,7 +103,7 @@ void checkThrows(any& a)
typename std::remove_reference<Type>::type&&,
Type
>::type;
any_cast<RefType>(static_cast<any&&>(a));
(void)any_cast<RefType>(static_cast<any&&>(a));
assert(false);
} catch (bad_any_cast const &) {
// do nothing

View File

@ -23,7 +23,7 @@ void test_max(size_t count)
{
std::allocator<T> a;
try {
a.allocate(count);
(void)a.allocate(count);
assert(false);
} catch (const std::exception &) {
}

View File

@ -134,7 +134,7 @@ int main()
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
ptr->shared_from_this();
(void)ptr->shared_from_this();
assert(false);
} catch (std::bad_weak_ptr const&) {
} catch (...) { assert(false); }

View File

@ -112,11 +112,11 @@ int main()
std::weak_ptr<int> wp1;
std::owner_less<> cmp;
cmp(sp1, sp2);
cmp(sp1, wp1);
cmp(sp1, sp3);
cmp(wp1, sp1);
cmp(wp1, wp1);
assert(!cmp(sp1, sp2));
assert(!cmp(sp1, wp1));
assert(!cmp(sp1, sp3));
assert(!cmp(wp1, sp1));
assert(!cmp(wp1, wp1));
ASSERT_NOEXCEPT(cmp(sp1, sp1));
ASSERT_NOEXCEPT(cmp(sp1, wp1));
ASSERT_NOEXCEPT(cmp(wp1, sp1));