Skip to content

Commit 8cabc84

Browse files
committed
issue #8017 C++: mishandling of brackets used in trailing return types
Handle `{` and `;` inside, nested, round brackets not as end of return type
1 parent b8398bd commit 8cabc84

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/scanner.l

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4583,13 +4583,29 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
45834583
lineCount(yyscanner);
45844584
yyextra->current->argList.setTrailingReturnType(" -> ");
45854585
yyextra->current->args += " -> ";
4586+
yyextra->roundCount=0;
45864587
BEGIN(TrailingReturn);
45874588
}
45884589
<TrailingReturn>[{;] {
4590+
if (yyextra->roundCount!= 0) REJECT;
45894591
unput(*yytext);
45904592
BEGIN(FuncQual);
45914593
}
45924594
<TrailingReturn>. {
4595+
if (*yytext == '(') yyextra->roundCount++;
4596+
else if (*yytext == ')')
4597+
{
4598+
if (yyextra->roundCount)
4599+
{
4600+
yyextra->roundCount--;
4601+
}
4602+
else
4603+
{
4604+
warn(yyextra->yyFileName,yyextra->yyLineNr,
4605+
"Found ')' without opening '(' for '%s)...'",
4606+
yyextra->current->argList.trailingReturnType().data());
4607+
}
4608+
}
45934609
yyextra->current->argList.setTrailingReturnType(yyextra->current->argList.trailingReturnType()+yytext);
45944610
yyextra->current->args+=yytext;
45954611
}

0 commit comments

Comments
 (0)