Skip to content

Commit 3df9500

Browse files
committed
review
1 parent b0e67d4 commit 3df9500

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎simplecpp.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static bool isAlternativeUnaryOp(const simplecpp::Token *tok, const std::string
222222
return false;
223223
// it is followed by the start of an operand
224224
const simplecpp::Token *next = tok->next;
225-
return next && (next->name || next->number || next->isOneOf("(!~+-"));
225+
return next && (next->name || isValue(next) || next->isOneOf("(!~+-"));
226226
}
227227

228228
static std::string replaceAll(std::string s, const std::string& from, const std::string& to)

‎test.cpp‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2869,7 +2869,10 @@ static void ifShortCircuit()
28692869
"defined(X) and X/0",
28702870
"0 && 1 bitor (1/0)",
28712871
"!(1 || (1/0) bitand 1)",
2872-
"0 and 1 xor (1/0)"
2872+
"0 and 1 xor (1/0)",
2873+
"0 && not (1/0)",
2874+
"0 && compl (1/0)",
2875+
"!(1 || not not (1/0))"
28732876
};
28742877
for (const char * const expr : exprs) {
28752878
const std::string code = std::string("#if ") + expr + "\n"
@@ -2886,6 +2889,9 @@ static void ifShortCircuit()
28862889
simplecpp::OutputList outputList;
28872890
ASSERT_EQUALS("", preprocess("#if 1 && (1/0)\n#endif\n", &outputList));
28882891
ASSERT_EQUALS("file0,1,syntax_error,failed to evaluate #if condition, division/modulo by zero\n", toString(outputList));
2892+
outputList.clear();
2893+
ASSERT_EQUALS("", preprocess("#if not (1/0)\n#endif\n", &outputList));
2894+
ASSERT_EQUALS("file0,1,syntax_error,failed to evaluate #if condition, division/modulo by zero\n", toString(outputList));
28892895
}
28902896

28912897
static void ifZeroCondition()

0 commit comments

Comments
 (0)