Restrict bit fields to having integer types, and to having no more bits than the type specified.

C89 restricts bit fields to (signed) int and unsigned int only, although later standards note that additional types may be supported. ORCA/C supports the other integer types as an extension.

This fixes the compco01.c test case.
This commit is contained in:
Stephen Heumann 2016-10-15 01:43:31 -05:00
parent f7c3c26794
commit 1077c35a49
2 changed files with 10 additions and 1 deletions

View File

@ -2512,7 +2512,15 @@ var
variable^.bitdisp := bitdisp;
variable^.bitsize := long(expressionValue).lsw;
bitdisp := bitdisp+long(expressionValue).lsw;
end; {if}
tPtr := variable^.itype;
end {if}
else
tPtr := typeSpec;
if (tPtr^.kind <> scalarType)
or not (tPtr^.baseType in
[cgByte,cgUByte,cgWord,cgUWord,cgLong,cgULong])
or (expressionValue > tPtr^.size*8) then
Error(115);
end {if}
else if variable <> nil then begin
if bitdisp <> 0 then begin

View File

@ -595,6 +595,7 @@ if list or (numErr <> 0) then begin
112: msg := @'segment buffer overflow';
113: msg := @'all parameters must have a name';
114: msg := @'a function call was made to a non-function';
115: msg := @'illegal bit field declaration';
otherwise: Error(57);
end; {case}
writeln(msg^);