Always allow the middle expression of a ? : expression to use the comma operator.

This should be allowed, but it previously could lead to spurious errors in contexts like argument lists, where a comma would normally be expected to end the expression.

The following example program demonstrated the problem:

#include <stdlib.h>
int main(void) {
        return abs(1 ? 2,-3 : 4);
}
This commit is contained in:
Stephen Heumann 2021-03-16 18:20:22 -05:00
parent 03f267ac02
commit debd0ccffc

View File

@ -2149,7 +2149,8 @@ if token.kind in startExpression then begin
end; {case}
if icp[token.kind] = notAnOperation then
done := true {end of expression found...}
else if (token.kind in stopSym) and (parenCount = 0) then
else if (token.kind in stopSym) and (parenCount = 0)
and ((opStack = nil) or (opStack^.token.kind <> questionch)) then
done := true
else begin
if not (kind in [normalExpression, autoInitializerExpression]) then