Skip to content

Commit ac523a8

Browse files
Update simplecpp.cpp
1 parent 6d45cd7 commit ac523a8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

simplecpp.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,14 @@ static bool isFloatSuffix(const simplecpp::Token *tok)
10051005
return c == 'f' || c == 'l';
10061006
}
10071007

1008+
static const std::string AND("and");
1009+
static const std::string BITAND("bitand");
1010+
static const std::string BITOR("bitor");
1011+
static bool isAlternativeAndBitandBitor(const simplecpp::Token* tok)
1012+
{
1013+
return isAlternativeBinaryOp(tok, AND) || isAlternativeBinaryOp(tok, BITAND) || isAlternativeBinaryOp(tok, BITOR);
1014+
}
1015+
10081016
void simplecpp::TokenList::combineOperators()
10091017
{
10101018
std::stack<bool> executableScope;
@@ -1040,7 +1048,7 @@ void simplecpp::TokenList::combineOperators()
10401048
if (tok->previous && tok->previous->number && sameline(tok->previous, tok) && tok->previous->str().find_first_of("._") == std::string::npos) {
10411049
tok->setstr(tok->previous->str() + '.');
10421050
deleteToken(tok->previous);
1043-
if (sameline(tok, tok->next) && (isFloatSuffix(tok->next) || (tok->next && tok->next->startsWithOneOf("AaBbCcDdEeFfPp")))) {
1051+
if (sameline(tok, tok->next) && (isFloatSuffix(tok->next) || (tok->next && tok->next->startsWithOneOf("AaBbCcDdEeFfPp") && !isAlternativeAndBitandBitor(tok->next)))) {
10441052
tok->setstr(tok->str() + tok->next->str());
10451053
deleteToken(tok->next);
10461054
}
@@ -1285,8 +1293,6 @@ void simplecpp::TokenList::constFoldComparison(Token *tok)
12851293
}
12861294
}
12871295

1288-
static const std::string BITAND("bitand");
1289-
static const std::string BITOR("bitor");
12901296
static const std::string XOR("xor");
12911297
void simplecpp::TokenList::constFoldBitwise(Token *tok)
12921298
{
@@ -1321,7 +1327,6 @@ void simplecpp::TokenList::constFoldBitwise(Token *tok)
13211327
}
13221328
}
13231329

1324-
static const std::string AND("and");
13251330
static const std::string OR("or");
13261331
void simplecpp::TokenList::constFoldLogicalOp(Token *tok)
13271332
{

0 commit comments

Comments
 (0)