Skip to content

Commit

Permalink
Fix #376: Member access on user-defined literal tokenized incorrectly (
Browse files Browse the repository at this point in the history
  • Loading branch information
ludviggunne authored Oct 21, 2024
1 parent d245956 commit d9edfb0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ void simplecpp::TokenList::combineOperators()
continue;
}
// float literals..
if (tok->previous && tok->previous->number && sameline(tok->previous, tok)) {
if (tok->previous && tok->previous->number && sameline(tok->previous, tok) && tok->previous->str().find_first_of("._") == std::string::npos) {
tok->setstr(tok->previous->str() + '.');
deleteToken(tok->previous);
if (sameline(tok, tok->next) && (isFloatSuffix(tok->next) || (tok->next && tok->next->startsWithOneOf("AaBbCcDdEeFfPp")))) {
Expand Down
2 changes: 2 additions & 0 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ static void combineOperators_floatliteral()
ASSERT_EQUALS("0x1p+3f", preprocess("0x1p+3f"));
ASSERT_EQUALS("0x1p+3L", preprocess("0x1p+3L"));
ASSERT_EQUALS("1p + 3", preprocess("1p+3"));
ASSERT_EQUALS("1.0_a . b", preprocess("1.0_a.b"));
ASSERT_EQUALS("1_a . b", preprocess("1_a.b"));
}

static void combineOperators_increment()
Expand Down

0 comments on commit d9edfb0

Please sign in to comment.