Add regression test for #9176 (#3319)

This commit is contained in:
chrchr-github 2021-07-01 13:58:00 +02:00 committed by GitHub
parent e1cff1d1ef
commit 9be88a06fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -69,6 +69,7 @@ private:
TEST_CASE(iterator23); TEST_CASE(iterator23);
TEST_CASE(iterator24); TEST_CASE(iterator24);
TEST_CASE(iterator25); // #9742 TEST_CASE(iterator25); // #9742
TEST_CASE(iterator26); // #9176
TEST_CASE(iteratorExpression); TEST_CASE(iteratorExpression);
TEST_CASE(iteratorSameExpression); TEST_CASE(iteratorSameExpression);
TEST_CASE(mismatchingContainerIterator); TEST_CASE(mismatchingContainerIterator);
@ -1353,6 +1354,20 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void iterator26() { // #9176
check(
"#include <map>\n"
"int main()\n"
"{"
" std::map<char const*, int> 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() { void iteratorExpression() {
check("std::vector<int>& f();\n" check("std::vector<int>& f();\n"
"std::vector<int>& g();\n" "std::vector<int>& g();\n"