This commit is contained in:
parent
842f2b2da7
commit
127b3bb1c4
|
@ -2141,7 +2141,7 @@ void TemplateSimplifier::expandTemplate(
|
|||
addNamespace(templateDeclaration, tok3);
|
||||
}
|
||||
mTokenList.addtoken(newName, tok3);
|
||||
} else if (!Token::Match(tok3->next(), ":|{|=|;"))
|
||||
} else if (!Token::Match(tok3->next(), ":|{|=|;|["))
|
||||
tok3->str(newName);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -5561,6 +5561,24 @@ private:
|
|||
"class C<int> { } ;";
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
{
|
||||
const char code[] = "class A {};\n"
|
||||
"template<typename T> struct B;\n"
|
||||
"template<> struct B<A> {};\n"
|
||||
"int f() {\n"
|
||||
" int B[1] = {};\n"
|
||||
" return B[0];\n"
|
||||
"}\n";
|
||||
const char expected[] = "class A { } ; "
|
||||
"struct B<A> ; "
|
||||
"template < typename T > struct B ; "
|
||||
"struct B<A> { } ; "
|
||||
"int f ( ) { "
|
||||
"int B [ 1 ] = { } ; "
|
||||
"return B [ 0 ] ; "
|
||||
"}";
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
}
|
||||
|
||||
void templateAlias1() {
|
||||
|
|
|
@ -5781,6 +5781,17 @@ private:
|
|||
" std::array<int, 1> a;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: a\n", errout.str());
|
||||
|
||||
functionVariableUsage("class A {};\n" // #9471
|
||||
" namespace std {\n"
|
||||
" template<>\n"
|
||||
" struct hash<A> {};\n"
|
||||
"}\n"
|
||||
"char f() {\n"
|
||||
" std::string hash = \"-\";\n"
|
||||
" return hash[0];\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvarFuncPtr() {
|
||||
|
|
Loading…
Reference in New Issue