Fixed #7410 (Tokenizer: function pointer with throw())

This commit is contained in:
Daniel Marjamäki 2016-02-29 08:02:02 +01:00
parent c5c376513b
commit 253bfe432c
2 changed files with 10 additions and 0 deletions

View File

@ -5267,6 +5267,8 @@ void Tokenizer::simplifyFunctionPointers()
syntaxError(nullptr);
}
Token *endTok = tok->link()->next()->link();
if (Token::simpleMatch(endTok, ") throw ("))
endTok = endTok->linkAt(2);
if (!Token::Match(endTok, ") const| ;|,|)|=|[|{"))
continue;

View File

@ -314,6 +314,7 @@ private:
TEST_CASE(functionpointer5);
TEST_CASE(functionpointer6);
TEST_CASE(functionpointer7);
TEST_CASE(functionpointer8); // #7410 - throw
TEST_CASE(removeRedundantAssignment);
@ -4718,6 +4719,13 @@ private:
ASSERT_EQUALS(expected1, tokenizeDebugListing(code1, false));
}
void functionpointer8() {
const char code1[] = "int (*f)() throw(int);";
const char expected1[] = "\n\n##file 0\n"
"1: int * f@1 ;\n";
ASSERT_EQUALS(expected1, tokenizeDebugListing(code1, false));
}
void removeRedundantAssignment() {
ASSERT_EQUALS("void f ( ) { }", tokenizeAndStringify("void f() { int *p, *q; p = q; }", true));
ASSERT_EQUALS("void f ( ) { }", tokenizeAndStringify("void f() { int *p = 0, *q; p = q; }", true));