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/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void Token::update_property_info()
else if (mTokType != eVariable && mTokType != eFunction && mTokType != eType && mTokType != eKeyword)
tokType(eName);
} else if (simplecpp::Token::isNumberLike(mStr)) {
if (MathLib::isInt(mStr) || MathLib::isFloat(mStr))
if ((MathLib::isInt(mStr) || MathLib::isFloat(mStr)) && mStr.find('_') == std::string::npos)
tokType(eNumber);
else
tokType(eName); // assume it is a user defined literal
Expand Down
12 changes: 12 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class TestTokenizer : public TestFixture {
TEST_CASE(tokenize37); // #8550
TEST_CASE(tokenize38); // #9569
TEST_CASE(tokenize39); // #9771
TEST_CASE(tokenize40); // #13181

TEST_CASE(validate);

Expand Down Expand Up @@ -826,6 +827,17 @@ class TestTokenizer : public TestFixture {
ASSERT_EQUALS(exp, tokenizeAndStringify(code));
}

void tokenize40() { // #13181
const char code[] = "struct A { double eps(double); };\n"
"A operator \"\"_a(long double);\n"
"void f() {\n"
" double d = 1.23;\n"
" if (d == 1.2_a .eps(.1)) {}\n"
"}\n";
(void) tokenizeAndStringify(code);
ASSERT_EQUALS("", errout_str());
}

void validate() {
// C++ code in C file
ASSERT_THROW_INTERNAL(tokenizeAndStringify(";using namespace std;",false,Platform::Type::Native,false), SYNTAX);
Expand Down