Allow the pascal qualifier to appear anywhere types are used.

This is necessary to allow declarations of pascal-qualified function pointers as members of a structure, among other things.

Note that the behavior for "pascal" now differs from that for the standard function specifiers, which have more restrictive rules for where they can be used. This is justified by the fact that the "pascal" qualifier is allowed and meaningful for function pointer types, so it should be able to appear anywhere they can.

This fixes #28.
This commit is contained in:
Stephen Heumann 2022-01-13 20:11:11 -06:00
parent b1bc840ec8
commit 6f0b94bb7c
2 changed files with 9 additions and 1 deletions

View File

@ -4032,6 +4032,7 @@ procedure TypeName;
var
tl,tp: typePtr; {for creating/reversing the type list}
isPascal: boolean; {is the type "pascal" qualified?}
procedure AbstractDeclarator;
@ -4181,6 +4182,7 @@ var
begin {TypeName}
{read and process the type specifier}
DeclarationSpecifiers(specifierQualifierListElement, rparench);
isPascal := pascalsy in declarationModifiers;
{_Alignas is not allowed in most uses of type names. }
{TODO: _Alignas should be allowed in compound literals. }
@ -4198,6 +4200,8 @@ while tl <> nil do begin {reverse the list & compute array sizes}
typeSpec := tl;
tl := tp;
end; {while}
if isPascal then
typeSpec := MakePascalType(typeSpec);
end; {TypeName}
@ -4713,7 +4717,7 @@ declarationSpecifiersElement := typeSpecifierStart + storageClassSpecifiers
+ typeQualifiers + functionSpecifiers + alignmentSpecifiers;
specifierQualifierListElement :=
typeSpecifierStart + typeQualifiers + alignmentSpecifiers;
typeSpecifierStart + typeQualifiers + alignmentSpecifiers + [pascalsy];
structDeclarationStart := specifierQualifierListElement + [_Static_assertsy];

View File

@ -1703,6 +1703,10 @@ int foo(int[42]);
(Chris Vavruska)
175. The pascal qualifier was not accepted in certain places where types are used. Among other things, this prevented pascal-qualified function pointers from being declared as members of a structure or union.
(Michael Hackett)
-- Bugs from C 2.1.0 that have been fixed -----------------------------------
1. In some situations, fread() reread the first 1K or so of the file.