From c8517eff87a6e10476def97d6d3a7f22b450df3b Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 7 May 2023 18:28:31 -0500 Subject: [PATCH] Give an error for sizeof(bitfield). This violates a constraint in the standards (C17 6.5.3.4 p1). --- Expression.pas | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Expression.pas b/Expression.pas index 8240db4..b4980ae 100644 --- a/Expression.pas +++ b/Expression.pas @@ -1712,12 +1712,16 @@ var if op^.token.kind = sizeofsy then begin op^.token.kind := ulongConst; op^.token.class := longConstant; - if op^.left^.token.kind = stringConst then + kindLeft := op^.left^.token.kind; + if kindLeft = stringConst then op^.token.lval := op^.left^.token.sval^.length else begin lCodeGeneration := codeGeneration; codeGeneration := false; GenerateCode(op^.left); + if kindLeft = dotch then + if isBitfield then + Error(49); codeGeneration := lCodeGeneration and (numErrors = 0); op^.token.lval := expressionType^.size; with expressionType^ do @@ -4690,6 +4694,7 @@ case tree^.token.kind of dotch: begin {.} LoadAddress(tree^.left, checkNullPointers); + isBitfield := false; lType := expressionType; if lType^.kind in [arrayType,pointerType,structType,unionType] then begin if lType^.kind = arrayType then