From b17269da754bfe8fba0e9342a4460a893f7c1259 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Sun, 17 Jul 2016 18:10:30 +0000 Subject: [PATCH] Fix warnings in ImmutableSetTest and SequenceTest. Doing "I++" inside of an EXPECT_* triggers warning: expression with side effects has no effect in an unevaluated context because EXPECT_* partially expands to EqHelper<(sizeof(::testing::internal::IsNullLiteralHelper(i++)) == 1)> which is an unevaluated context. llvm-svn: 275717 --- llvm/unittests/ADT/ImmutableSetTest.cpp | 9 ++++++--- llvm/unittests/ADT/SequenceTest.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/llvm/unittests/ADT/ImmutableSetTest.cpp b/llvm/unittests/ADT/ImmutableSetTest.cpp index febd441..a6eb405 100644 --- a/llvm/unittests/ADT/ImmutableSetTest.cpp +++ b/llvm/unittests/ADT/ImmutableSetTest.cpp @@ -181,19 +181,22 @@ TEST_F(ImmutableSetTest, IterLongSetTest) { int i = 0; for (ImmutableSet::iterator I = S.begin(), E = S.end(); I != E; ++I) { - ASSERT_EQ(i++, *I); + ASSERT_EQ(i, *I); + i++; } ASSERT_EQ(0, i); i = 0; for (ImmutableSet::iterator I = S2.begin(), E = S2.end(); I != E; ++I) { - ASSERT_EQ(i++, *I); + ASSERT_EQ(i, *I); + i++; } ASSERT_EQ(3, i); i = 0; for (ImmutableSet::iterator I = S3.begin(), E = S3.end(); I != E; I++) { - ASSERT_EQ(i++, *I); + ASSERT_EQ(i, *I); + i++; } ASSERT_EQ(6, i); } diff --git a/llvm/unittests/ADT/SequenceTest.cpp b/llvm/unittests/ADT/SequenceTest.cpp index d82c3c2..cc82f86 100644 --- a/llvm/unittests/ADT/SequenceTest.cpp +++ b/llvm/unittests/ADT/SequenceTest.cpp @@ -18,8 +18,10 @@ namespace { TEST(SequenceTest, Basic) { int x = 0; - for (int i : seq(0, 10)) - EXPECT_EQ(x++, i); + for (int i : seq(0, 10)) { + EXPECT_EQ(x, i); + x++; + } EXPECT_EQ(10, x); auto my_seq = seq(0, 4); -- 2.7.4