From b1d4d8d6685ad14a3d2dbb9e958d618b549c3247 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Fri, 29 Jan 2021 12:49:28 -0600 Subject: [PATCH] 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; } --- Expression.pas | 6 ++++-- cc.notes | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Expression.pas b/Expression.pas index 07752a8..e0814e4 100644 --- a/Expression.pas +++ b/Expression.pas @@ -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))); diff --git a/cc.notes b/cc.notes index 6a4a913..2b74ba9 100644 --- a/cc.notes +++ b/cc.notes @@ -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.