Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3002,7 +3002,7 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
bracket = true; // Skip: Seems to be valid pointer to array or function pointer
} else if (tok2->str() == "::") {
singleNameCount = 0;
} else if (tok2->str() != "*" && tok2->str() != "::") {
} else if (tok2->str() != "*" && tok2->str() != "::" && tok2->str() != "...") {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will thie be executed for C code as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but it is already checking for "::" in a few places without checking the language. Should they all be fixed?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that we don't need special handling of C code for ::.. valid C code does not contain that operator.

But ... can be used in C code. However if there is valid C code that contains ... I would assume that should be handled the same way in C++ mode... so this either does not break C or it breaks both C and C++ parsing.

break;
}
tok2 = tok2->next();
Expand Down
13 changes: 13 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class TestVarID : public TestFixture {
TEST_CASE(varid_lambda_mutable);
TEST_CASE(varid_trailing_return1); // #8889
TEST_CASE(varid_trailing_return2); // #9066
TEST_CASE(varid_parameter_pack); // #9383

TEST_CASE(varidclass1);
TEST_CASE(varidclass2);
Expand Down Expand Up @@ -2535,6 +2536,18 @@ class TestVarID : public TestFixture {
ASSERT_EQUALS(exp1, tokenize(code1));
}

void varid_parameter_pack() { // #9383
const char code1[] = "template <typename... Rest>\n"
"void func(Rest... parameters) {\n"
" foo(parameters...);\n"
"}\n";
const char exp1[] = "1: template < typename ... Rest >\n"
"2: void func ( Rest ... parameters@1 ) {\n"
"3: foo ( parameters@1 ... ) ;\n"
"4: }\n";
ASSERT_EQUALS(exp1, tokenize(code1));
}

void varidclass1() {
const std::string actual = tokenize(
"class Fred\n"
Expand Down