From b019c5980381d7ae085bde44dea33539523a9da1 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sat, 15 Oct 2016 19:47:06 -0500 Subject: [PATCH] Flag an error if a struct or enum field declaration contains no declarator (i.e. no name). This may be someone trying to use a C11-style anonymous struct/union, which should be flagged as an error until and unless those are supported. Otherwise, it probably just indicates that the programmer is confused. In any case, an error should be flagged for it. --- Parser.pas | 8 ++++++-- Scanner.pas | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Parser.pas b/Parser.pas index 5e55afb..8ad9749 100644 --- a/Parser.pas +++ b/Parser.pas @@ -2535,7 +2535,9 @@ var disp := disp + variable^.itype^.size; if disp > maxDisp then maxDisp := disp; - end; {if} + end {if} + else + Error(116); if token.kind = commach then {allow repeated declarations} begin NextToken; @@ -2543,7 +2545,9 @@ var end {if} else done := true; - until done or (token.kind = eofsy); + until done or (token.kind = eofsy) + else + Error(116); Match(semicolonch,22); {insist on a closing ';'} end; {while} if fl <> nil then begin diff --git a/Scanner.pas b/Scanner.pas index 20000ca..87838a2 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -533,7 +533,7 @@ if list or (numErr <> 0) then begin 50: msg := @'only parameters or types may be declared here'; 51: msg := @'lint: undefined function'; 52: msg := @'you cannot initialize a type'; - 53: msg := @'the structure has already been defined'; + 53: msg := @'the structure or union has already been defined'; 54: msg := @'bit fields must be less than 32 bits wide'; 55: msg := @'a value cannot be zero bits wide'; 56: msg := @'bit fields in unions are not supported by ORCA/C'; @@ -596,6 +596,7 @@ if list or (numErr <> 0) then begin 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'; + 116: msg := @'missing field name'; otherwise: Error(57); end; {case} writeln(msg^);