mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-08-15 07:27:27 +00:00
Give errors for most illegal uses of "restrict".
This commit is contained in:
20
Parser.pas
20
Parser.pas
@@ -2864,6 +2864,10 @@ while token.kind in allowedTokens do begin
|
|||||||
|
|
||||||
restrictsy: begin
|
restrictsy: begin
|
||||||
myDeclarationModifiers := myDeclarationModifiers + [token.kind];
|
myDeclarationModifiers := myDeclarationModifiers + [token.kind];
|
||||||
|
if typeDone or (typeSpecifiers <> []) then
|
||||||
|
if (myTypeSpec^.kind <> pointerType)
|
||||||
|
or (myTypeSpec^.pType^.kind = functionType) then
|
||||||
|
Error(143);
|
||||||
NextToken;
|
NextToken;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -2896,6 +2900,10 @@ while token.kind in allowedTokens do begin
|
|||||||
UnexpectedTokenError(expectedNext);
|
UnexpectedTokenError(expectedNext);
|
||||||
end {if}
|
end {if}
|
||||||
else begin
|
else begin
|
||||||
|
if restrictsy in myDeclarationModifiers then begin
|
||||||
|
myDeclarationModifiers := myDeclarationModifiers - [restrictsy];
|
||||||
|
Error(143);
|
||||||
|
end; {if}
|
||||||
typeSpecifiers := typeSpecifiers + [token.kind];
|
typeSpecifiers := typeSpecifiers + [token.kind];
|
||||||
ResolveType;
|
ResolveType;
|
||||||
end; {else}
|
end; {else}
|
||||||
@@ -2909,7 +2917,9 @@ while token.kind in allowedTokens do begin
|
|||||||
|
|
||||||
enumsy: begin {enum}
|
enumsy: begin {enum}
|
||||||
if typeDone or (typeSpecifiers <> []) then
|
if typeDone or (typeSpecifiers <> []) then
|
||||||
UnexpectedTokenError(expectedNext);
|
UnexpectedTokenError(expectedNext)
|
||||||
|
else if restrictsy in myDeclarationModifiers then
|
||||||
|
Error(143);
|
||||||
NextToken; {skip the 'enum' token}
|
NextToken; {skip the 'enum' token}
|
||||||
if token.kind = ident then begin {handle a type definition}
|
if token.kind = ident then begin {handle a type definition}
|
||||||
variable := FindSymbol(token, tagSpace, true, true);
|
variable := FindSymbol(token, tagSpace, true, true);
|
||||||
@@ -2979,7 +2989,9 @@ while token.kind in allowedTokens do begin
|
|||||||
structsy, {struct}
|
structsy, {struct}
|
||||||
unionsy: begin {union}
|
unionsy: begin {union}
|
||||||
if typeDone or (typeSpecifiers <> []) then
|
if typeDone or (typeSpecifiers <> []) then
|
||||||
UnexpectedTokenError(expectedNext);
|
UnexpectedTokenError(expectedNext)
|
||||||
|
else if restrictsy in myDeclarationModifiers then
|
||||||
|
Error(143);
|
||||||
globalStruct := false; {we didn't make it global}
|
globalStruct := false; {we didn't make it global}
|
||||||
if token.kind = structsy then {set the type kind to use}
|
if token.kind = structsy then {set the type kind to use}
|
||||||
tKind := structType
|
tKind := structType
|
||||||
@@ -3066,6 +3078,10 @@ while token.kind in allowedTokens do begin
|
|||||||
typedef: begin {named type definition}
|
typedef: begin {named type definition}
|
||||||
if (typeSpecifiers = []) and not typeDone then begin
|
if (typeSpecifiers = []) and not typeDone then begin
|
||||||
myTypeSpec := token.symbolPtr^.itype;
|
myTypeSpec := token.symbolPtr^.itype;
|
||||||
|
if restrictsy in myDeclarationModifiers then
|
||||||
|
if (myTypeSpec^.kind <> pointerType)
|
||||||
|
or (myTypeSpec^.pType^.kind = functionType) then
|
||||||
|
Error(143);
|
||||||
NextToken;
|
NextToken;
|
||||||
typeDone := true;
|
typeDone := true;
|
||||||
end {if}
|
end {if}
|
||||||
|
@@ -664,6 +664,7 @@ if list or (numErr <> 0) then begin
|
|||||||
140: msg := @'unexpected token';
|
140: msg := @'unexpected token';
|
||||||
141: msg := @'_Noreturn specifier is only allowed on functions';
|
141: msg := @'_Noreturn specifier is only allowed on functions';
|
||||||
142: msg := @'_Alignas may not be used in this declaration or type name';
|
142: msg := @'_Alignas may not be used in this declaration or type name';
|
||||||
|
143: msg := @'only object pointer types may be restrict-qualified';
|
||||||
otherwise: Error(57);
|
otherwise: Error(57);
|
||||||
end; {case}
|
end; {case}
|
||||||
writeln(msg^);
|
writeln(msg^);
|
||||||
|
Reference in New Issue
Block a user