Allow string constants in initializers for arrays of char*.

For example, declarations like the following should be accepted:

char *p[] = {"abc", "def"};

This previously worked, but it was broken by commit 5871820e0c.
This commit is contained in:
Stephen Heumann 2021-11-12 21:14:15 -06:00
parent c1b2a88a84
commit 7ac3fe6424

View File

@ -2491,9 +2491,9 @@ var
kind := ktp^.kind;
{handle string constants}
if token.kind = stringConst then begin
if token.kind = stringConst then
stringElementType := StringType(token.prefix)^.aType;
if (kind = scalarType) and
if (token.kind = stringConst) and (kind = scalarType) and
(((ktp^.baseType in [cgByte,cgUByte])
and (stringElementType = charPtr))
or CompTypes(ktp,stringElementType)) then begin
@ -2541,14 +2541,8 @@ var
end; {with}
NextToken;
end {if}
else begin
Error(47);
errorFound := true;
NextToken;
end; {else}
end {if}
{handle arrays of non-strings}
{handle arrays not initialized with a string constant}
else if kind in
[scalarType,pointerType,enumType,arrayType,structType,unionType] then
begin