Skip to content

Commit 27b164c

Browse files
committed
fix #14077
* allow member access on user defined literals * allow (tokens that look like) user defined literals in msvc asm blocks
1 parent 05cdcf1 commit 27b164c

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

lib/token.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void Token::update_property_info()
153153
if ((MathLib::isInt(mStr) || MathLib::isFloat(mStr)) && mStr.find('_') == std::string::npos)
154154
tokType(eNumber);
155155
else
156-
tokType(eName); // assume it is a user defined literal
156+
tokType(eLiteral); // assume it is a user defined literal
157157
} else if (mStr == "=" || mStr == "<<=" || mStr == ">>=" ||
158158
(mStr.size() == 2U && mStr[1] == '=' && std::strchr("+-*/%&^|", mStr[0])))
159159
tokType(eAssignmentOp);

lib/tokenize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8869,6 +8869,7 @@ void Tokenizer::findGarbageCode() const
88698869
!Token::simpleMatch(tok->previous(), ".") &&
88708870
!Token::simpleMatch(tok->next(), ".") &&
88718871
!Token::Match(tok->previous(), "{|, . %name% =|.|[|{") &&
8872+
!(tok->previous() && tok->previous()->isLiteral()) &&
88728873
!Token::Match(tok->previous(), ", . %name%")) {
88738874
if (!Token::Match(tok->previous(), "%name%|)|]|>|}"))
88748875
syntaxError(tok, tok->strAt(-1) + " " + tok->str() + " " + tok->strAt(1));
@@ -9877,7 +9878,7 @@ void Tokenizer::simplifyAsm()
98779878
Token *endasm = tok->next();
98789879
const Token *firstSemiColon = nullptr;
98799880
int comment = 0;
9880-
while (Token::Match(endasm, "%num%|%name%|,|:|;") || (endasm && endasm->linenr() == comment)) {
9881+
while (Token::Match(endasm, "%num%|%name%|,|:|;") || (endasm && (endasm->isLiteral() || endasm->linenr() == comment))) {
98819882
if (Token::Match(endasm, "_asm|__asm|__endasm"))
98829883
break;
98839884
if (endasm->str() == ";") {

0 commit comments

Comments
 (0)