From 9be88a06feb0d4da6165bdfd530395403ed3e870 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 1 Jul 2021 13:58:00 +0200 Subject: [PATCH] Add regression test for #9176 (#3319) --- test/teststl.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/teststl.cpp b/test/teststl.cpp index 39bacbb4d..bc274da7b 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -69,6 +69,7 @@ private: TEST_CASE(iterator23); TEST_CASE(iterator24); TEST_CASE(iterator25); // #9742 + TEST_CASE(iterator26); // #9176 TEST_CASE(iteratorExpression); TEST_CASE(iteratorSameExpression); TEST_CASE(mismatchingContainerIterator); @@ -1353,6 +1354,20 @@ private: ASSERT_EQUALS("", errout.str()); } + void iterator26() { // #9176 + check( + "#include \n" + "int main()\n" + "{" + " std::map m{ {\"a\", 1} };\n" + " if (auto iter = m.find(\"x\"); iter != m.end()) {\n" + " return iter->second;\n" + " }\n" + " return 0;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void iteratorExpression() { check("std::vector& f();\n" "std::vector& g();\n"