mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-02 19:29:21 +00:00
Recognize designated initializers enough to give an error and skip them.
Previously, the designated initializer syntax could confuse the parser enough to cause null pointer dereferences. This avoids that, and also gives a more meaningful error message to the user.
This commit is contained in:
parent
58630dedc1
commit
f5cd1e3e3a
19
Parser.pas
19
Parser.pas
@ -1896,6 +1896,25 @@ var
|
||||
|
||||
|
||||
begin {GetInitializerValue}
|
||||
if token.kind in [dotch,lbrackch] then begin
|
||||
{designated initializer: give error and skip over it}
|
||||
Error(150);
|
||||
while token.kind in [dotch,lbrackch] do begin
|
||||
if token.kind = lbrackch then begin
|
||||
NextToken;
|
||||
Expression(arrayExpression, [rbrackch]);
|
||||
if token.kind = rbrackch then
|
||||
NextToken;
|
||||
end {if}
|
||||
else {if token.kind = dotch then} begin
|
||||
NextToken;
|
||||
if token.kind in [ident,typedef] then
|
||||
NextToken;
|
||||
end {if}
|
||||
end; {while}
|
||||
if token.kind = eqch then
|
||||
NextToken;
|
||||
end; {if}
|
||||
if variable^.storage = stackFrame then
|
||||
Expression(autoInitializerExpression, [commach,rparench,rbracech])
|
||||
else
|
||||
|
@ -672,6 +672,7 @@ if list or (numErr <> 0) then begin
|
||||
147: msg := @'lint: not all parameters were declared with a type';
|
||||
148: msg := @'all parameters must have a complete type';
|
||||
149: msg := @'invalid universal character name for use in an identifier';
|
||||
150: msg := @'designated initializers are not supported by ORCA/C';
|
||||
otherwise: Error(57);
|
||||
end; {case}
|
||||
writeln(msg^);
|
||||
|
Loading…
Reference in New Issue
Block a user