Give errors for certain illegal initializers.

This prohibits initializers in "extern" declarations within a function, and in the parameter declarations of non-prototyped functions.

Here are examples illustrating these cases:

int main(void) {
        extern int i = 50;
}

void f(i)
int i = 60;
{
}
This commit is contained in:
Stephen Heumann 2023-04-06 12:48:43 -05:00
parent 4c903a5331
commit 20f9170343
1 changed files with 5 additions and 2 deletions

View File

@ -4123,8 +4123,11 @@ else {if not isFunction then} begin
Error(141);
if token.kind = eqch then begin
if declSpecifiers.storageClass = typedefsy then
Error(52);
if doingPrototypes then
Error(52)
else if declSpecifiers.storageClass = externsy then
if doingFunction then
Error(22);
if doingPrototypes or doingParameters then
Error(88);
{allocate copy of incomplete array type,}
tp := variable^.itype; {so it can be completed by Initializer}