Skip to content

Commit d329ee9

Browse files
Fix #14400 FP syntaxError for trailing return type (danmar#8127)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent a8f83c1 commit d329ee9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static bool isClassStructUnionEnumStart(const Token * tok)
110110
const Token * tok2 = tok->previous();
111111
while (tok2 && !Token::Match(tok2, "class|struct|union|enum|{|}|)|;|>|>>"))
112112
tok2 = tok2->previous();
113-
return Token::Match(tok2, "class|struct|union|enum");
113+
return Token::Match(tok2, "class|struct|union|enum") && !Token::simpleMatch(tok2->tokAt(-1), "->");
114114
}
115115

116116
//---------------------------------------------------------------------------

test/testtokenize.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7683,6 +7683,12 @@ class TestTokenizer : public TestFixture {
76837683

76847684
ASSERT_NO_THROW(tokenizeAndStringify("struct S { unsigned u:2, :30; };")); // #14393
76857685

7686+
ASSERT_NO_THROW(tokenizeAndStringify("struct S {};\n" // #14400
7687+
"auto f(bool b) -> struct S {\n"
7688+
" if (b) {}\n"
7689+
" return {};\n"
7690+
"};\n"));
7691+
76867692
ignore_errout();
76877693
}
76887694

0 commit comments

Comments
 (0)