Fixed #1307 (Internal error with typedef in parameter list)
This commit is contained in:
parent
724c55b32a
commit
989e8393e4
|
@ -684,12 +684,22 @@ void Tokenizer::simplifyTypedef()
|
||||||
if (!inCast)
|
if (!inCast)
|
||||||
{
|
{
|
||||||
if (tok2->next()->str() != ")" && tok2->next()->str() != ",")
|
if (tok2->next()->str() != ")" && tok2->next()->str() != ",")
|
||||||
|
{
|
||||||
|
if (Token::Match(tok2->next(), "( * %type% ) ("))
|
||||||
|
tok2 = tok2->tokAt(5)->link();
|
||||||
|
else
|
||||||
{
|
{
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
|
|
||||||
// skip over typedef parameter
|
// skip over typedef parameter
|
||||||
if (tok2->next()->str() == "(")
|
if (tok2->next()->str() == "(")
|
||||||
|
{
|
||||||
tok2 = tok2->next()->link();
|
tok2 = tok2->next()->link();
|
||||||
|
|
||||||
|
if (tok2->next()->str() == "(")
|
||||||
|
tok2 = tok2->next()->link();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,7 @@ private:
|
||||||
TEST_CASE(simplifyTypedef23);
|
TEST_CASE(simplifyTypedef23);
|
||||||
TEST_CASE(simplifyTypedef24);
|
TEST_CASE(simplifyTypedef24);
|
||||||
TEST_CASE(simplifyTypedef25);
|
TEST_CASE(simplifyTypedef25);
|
||||||
|
TEST_CASE(simplifyTypedef26);
|
||||||
TEST_CASE(reverseArraySyntax)
|
TEST_CASE(reverseArraySyntax)
|
||||||
TEST_CASE(simplify_numeric_condition)
|
TEST_CASE(simplify_numeric_condition)
|
||||||
|
|
||||||
|
@ -2890,6 +2891,34 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyTypedef26()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
const char code[] = "typedef void (*Callback) ();\n"
|
||||||
|
"void addCallback(Callback (*callback)());";
|
||||||
|
|
||||||
|
const char expected[] =
|
||||||
|
"; "
|
||||||
|
"void addCallback ( void ( * ( * callback ) ( ) ) ( ) ) ;";
|
||||||
|
|
||||||
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// ticket # 1307
|
||||||
|
const char code[] = "typedef void (*pc_video_update_proc)(bitmap_t *bitmap,\n"
|
||||||
|
"struct mscrtc6845 *crtc);\n"
|
||||||
|
"\n"
|
||||||
|
"struct mscrtc6845 *pc_video_start(pc_video_update_proc (*choosevideomode)(running_machine *machine, int *width, int *height, struct mscrtc6845 *crtc));";
|
||||||
|
|
||||||
|
const char expected[] =
|
||||||
|
"; "
|
||||||
|
"struct mscrtc6845 * pc_video_start ( void ( * ( * choosevideomode ) ( running_machine * machine , int * width , int * height , struct mscrtc6845 * crtc ) ) ( bitmap_t * bitmap , struct mscrtc6845 * crtc ) ) ;";
|
||||||
|
|
||||||
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void reverseArraySyntax()
|
void reverseArraySyntax()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
||||||
|
|
Loading…
Reference in New Issue