Fix #1366 (void Tokenizer::simplifyTemplates() --> Abort)
http://sourceforge.net/apps/trac/cppcheck/ticket/1366
This commit is contained in:
parent
8853f304af
commit
45abd2d7fc
|
@ -1560,7 +1560,7 @@ void Tokenizer::simplifyTemplates()
|
||||||
|
|
||||||
else if (tok3->str() == "}")
|
else if (tok3->str() == "}")
|
||||||
{
|
{
|
||||||
if (indentlevel <= 1)
|
if (indentlevel <= 1 && brackets.empty() && brackets2.empty())
|
||||||
{
|
{
|
||||||
// there is a bug if indentlevel is 0
|
// there is a bug if indentlevel is 0
|
||||||
// the "}" token should only be added if indentlevel is 1 but I add it always intentionally
|
// the "}" token should only be added if indentlevel is 1 but I add it always intentionally
|
||||||
|
|
|
@ -192,6 +192,7 @@ private:
|
||||||
TEST_CASE(removeRedundantAssignment);
|
TEST_CASE(removeRedundantAssignment);
|
||||||
|
|
||||||
TEST_CASE(removedeclspec);
|
TEST_CASE(removedeclspec);
|
||||||
|
TEST_CASE(cpp0xtemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3004,6 +3005,18 @@ private:
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("a b", tokenizeAndStringify("a __declspec ( dllexport ) b"));
|
ASSERT_EQUALS("a b", tokenizeAndStringify("a __declspec ( dllexport ) b"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cpp0xtemplate()
|
||||||
|
{
|
||||||
|
const char *code = "template <class T>\n"
|
||||||
|
"void fn2 (T t = []{return 1;}())\n"
|
||||||
|
"{}\n"
|
||||||
|
"int main()\n"
|
||||||
|
"{\n"
|
||||||
|
" fn2<int>();\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS(";\n\n\nint main ( )\n{\nfn2<int> ( ) ;\n}void fn2<int> ( int t = [ ] { return 1 ; } ( ) )\n{ }", tokenizeAndStringify(code));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestTokenizer)
|
REGISTER_TEST(TestTokenizer)
|
||||||
|
|
Loading…
Reference in New Issue