Allow floating literals that are immediately cast to integer types to appear in integer constant expressions.

The C standards say these should be permitted. The following declaration shows an example:

int a[(int)5.5];
This commit is contained in:
Stephen Heumann 2016-12-19 14:36:48 -06:00
parent 0cf948e3bd
commit 7fa74d1183
1 changed files with 7 additions and 0 deletions

View File

@ -1562,6 +1562,13 @@ if token.kind in startExpression then begin
if token.kind in [stringconst,doubleconst] then begin
if kind = arrayExpression then begin
op := opStack;
if token.kind = doubleconst then
if op <> nil then
if op^.token.kind = castoper then
if op^.casttype^.kind = scalarType then
if op^.casttype^.baseType in [cgByte,cgUByte,
cgWord,cgUWord,cgLong,cgULong] then
goto 3;
while op <> nil do begin
if op^.token.kind = sizeofsy then
goto 3;