Give errors for certain invalid compound assignment expressions.

The following example shows cases that were erroneously permitted before:

int main(void) {
        int i, *p;
        i *= p;
        i <<= 5.0;
        i <<= (void)1;
}
This commit is contained in:
Stephen Heumann 2021-01-29 12:49:28 -06:00
parent 5dbe632f33
commit b1d4d8d668
2 changed files with 6 additions and 2 deletions

View File

@ -3011,11 +3011,13 @@ case tree^.token.kind of
kind := lType^.kind;
GenerateCode(tree^.right);
if expressionType^.kind <> scalarType then
if tree^.token.kind in [pluseqop,minuseqop] then
Error(66);
Error(66);
if tree^.token.kind in [gtgteqop,ltlteqop] then
if kind = scalarType then
if expressionType^.kind = scalarType then begin
if expressionType^.baseType in
[cgReal,cgDouble,cgComp,cgExtended,cgVoid] then
Error(66);
et := UsualUnaryConversions;
if et <> Unary(ltype^.baseType) then begin
Gen2(pc_cnv, et, ord(Unary(ltype^.baseType)));

View File

@ -998,6 +998,8 @@ int foo(int[42]);
128. The ++ and -- operators often would not work correctly on bit-fields, or on floating-point values that were in a structure or were accessed via a pointer.
129. Certain invalid compound assignment expressions were erroneously permitted.
-- Bugs from C 2.1.0 that have been fixed -----------------------------------
1. In some situations, fread() reread the first 1K or so of the file.