Add regression test for #8994 (#1733)

Trac ticket #8994 was fixed in b222953bae.
Add a regression test to ensure it stays fixed.
This commit is contained in:
Rikard Falkeborn 2019-03-11 06:14:37 +01:00 committed by Daniel Marjamäki
parent b9d2a1291c
commit a4269042e8
1 changed files with 32 additions and 0 deletions

View File

@ -224,6 +224,8 @@ private:
TEST_CASE(shadowVariables);
TEST_CASE(constArgument);
TEST_CASE(checkComparePointers);
TEST_CASE(unusedVariableValueTemplate); // #8994
}
void check(const char code[], const char *filename = nullptr, bool experimental = false, bool inconclusive = true, bool runSimpleChecks=true, bool verbose=false, Settings* settings = 0) {
@ -7710,6 +7712,36 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
}
void unusedVariableValueTemplate() {
check("#include <functional>\n"
"class A\n"
"{\n"
"public:\n"
" class Hash\n"
" {\n"
" public:\n"
" std::size_t operator()(const A& a) const\n"
" {\n"
" (void)a;\n"
" return 0;\n"
" }\n"
" };\n"
"};\n"
"namespace std\n"
"{\n"
" template <>\n"
" struct hash<A>\n"
" {\n"
" std::size_t operator()(const A& a) const noexcept\n"
" {\n"
" return A::Hash{}(a);\n"
" }\n"
" };\n"
"}");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestOther)