mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-26 03:32:45 +00:00
Handle alignas/alignof/bool/static_assert/thread_local keywords (C23).
These are now treated equivalently to the old versions that start with _. Note that thread_localsy and alignassy are canonicalized to _Thread_localsy and _Alignassy when recorded as declaration modifiers.
This commit is contained in:
parent
9ecbd42c1a
commit
f125a6640c
@ -1715,6 +1715,7 @@ var
|
||||
opminusminus, {postfix --}
|
||||
sizeofsy, {sizeof}
|
||||
_Alignofsy, {_Alignof (erroneous uses)}
|
||||
alignofsy,
|
||||
castoper, {(type)}
|
||||
typedef, {(type-name)}
|
||||
tildech, {~}
|
||||
@ -1747,7 +1748,7 @@ var
|
||||
op^.left := nil;
|
||||
end {if sizeofsy}
|
||||
|
||||
else if op^.token.kind = _Alignofsy then begin
|
||||
else if op^.token.kind in [_Alignofsy,alignofsy] then begin
|
||||
{error case: operand of _Alignof is not a parenthesized type-name}
|
||||
Error(36);
|
||||
op^.token.kind := ulongConst;
|
||||
@ -2284,7 +2285,7 @@ if token.kind in startExpression then begin
|
||||
if opStack <> nil then
|
||||
if opStack^.token.kind = sizeofsy then
|
||||
doingSizeof := true
|
||||
else if opStack^.token.kind = _Alignofsy then
|
||||
else if opStack^.token.kind in [_Alignofsy,alignofsy] then
|
||||
doingAlignof := true;
|
||||
tType := TypeName;
|
||||
Match(rparench,12);
|
||||
@ -2375,8 +2376,8 @@ if token.kind in startExpression then begin
|
||||
errorFound := true;
|
||||
end; {if}
|
||||
if token.kind in {make sure we get what we want}
|
||||
[plusplusop,minusminusop,sizeofsy,_Alignofsy,tildech,excch,
|
||||
uasterisk,uminus,uplus,uand] then begin
|
||||
[plusplusop,minusminusop,sizeofsy,_Alignofsy,alignofsy,tildech,
|
||||
excch,uasterisk,uminus,uplus,uand] then begin
|
||||
if not expectingTerm then begin
|
||||
Error(38);
|
||||
Skip;
|
||||
@ -5043,7 +5044,7 @@ startTerm := [ident,intconst,uintconst,longconst,ulongconst,longlongconst,
|
||||
charconst,scharconst,ucharconst,ushortconst,stringconst];
|
||||
startExpression:= startTerm +
|
||||
[lparench,asteriskch,andch,plusch,minusch,excch,tildech,sizeofsy,
|
||||
plusplusop,minusminusop,typedef,_Alignofsy,_Genericsy];
|
||||
plusplusop,minusminusop,typedef,_Alignofsy,alignofsy,_Genericsy];
|
||||
end; {InitExpression}
|
||||
|
||||
end.
|
||||
|
32
Parser.pas
32
Parser.pas
@ -2903,7 +2903,7 @@ var
|
||||
fl := nil; {nothing in the field list, yet}
|
||||
{while there are entries in the field list...}
|
||||
1: while token.kind in structDeclarationStart do begin
|
||||
if token.kind = _Static_assertsy then begin
|
||||
if token.kind in [_Static_assertsy,static_assertsy] then begin
|
||||
DoStaticAssert;
|
||||
goto 1;
|
||||
end; {if}
|
||||
@ -3132,7 +3132,8 @@ var
|
||||
myTypeSpec := extendedPtr
|
||||
else if typeSpecifiers = [compsy] then
|
||||
myTypeSpec := compPtr
|
||||
else if typeSpecifiers = [_Boolsy] then begin
|
||||
else if (typeSpecifiers = [_Boolsy])
|
||||
or (typeSpecifiers = [boolsy]) then begin
|
||||
myTypeSpec := boolPtr;
|
||||
end {else if}
|
||||
else
|
||||
@ -3185,8 +3186,8 @@ while token.kind in allowedTokens do begin
|
||||
NextToken;
|
||||
end;
|
||||
|
||||
_Thread_localsy: begin
|
||||
myDeclarationModifiers := myDeclarationModifiers + [token.kind];
|
||||
_Thread_localsy,thread_localsy: begin
|
||||
myDeclarationModifiers := myDeclarationModifiers + [_Thread_localsy];
|
||||
if doingParameters then
|
||||
Error(87);
|
||||
if not (myStorageClass in [ident,staticsy,externsy]) then
|
||||
@ -3241,7 +3242,7 @@ while token.kind in allowedTokens do begin
|
||||
|
||||
{type specifiers}
|
||||
unsignedsy,signedsy,intsy,longsy,charsy,shortsy,floatsy,doublesy,voidsy,
|
||||
compsy,extendedsy,_Boolsy: begin
|
||||
compsy,extendedsy,_Boolsy,boolsy: begin
|
||||
if typeDone then
|
||||
Error(badNextTokenError)
|
||||
else if token.kind in typeSpecifiers then begin
|
||||
@ -3480,8 +3481,8 @@ while token.kind in allowedTokens do begin
|
||||
end;
|
||||
|
||||
{alignment specifier}
|
||||
_Alignassy: begin
|
||||
myDeclarationModifiers := myDeclarationModifiers + [token.kind];
|
||||
_Alignassy,alignassy: begin
|
||||
myDeclarationModifiers := myDeclarationModifiers + [_Alignassy];
|
||||
NextToken;
|
||||
Match(lparench, 13);
|
||||
if token.kind in specifierQualifierListElement then begin
|
||||
@ -3751,7 +3752,7 @@ var
|
||||
begin {DoDeclaration}
|
||||
lInhibitHeader:= inhibitHeader;
|
||||
inhibitHeader := true; {block imbedded includes in headers}
|
||||
if token.kind = _Static_assertsy then begin
|
||||
if token.kind in [_Static_assertsy,static_assertsy] then begin
|
||||
DoStaticAssert;
|
||||
goto 4;
|
||||
end; {if}
|
||||
@ -4746,18 +4747,18 @@ anonNumber := 0; {no anonymous structs/unions yet}
|
||||
{See C17 section 6.7 ff.}
|
||||
typeSpecifierStart :=
|
||||
[voidsy,charsy,shortsy,intsy,longsy,floatsy,doublesy,signedsy,unsignedsy,
|
||||
extendedsy,compsy,_Boolsy,_Complexsy,_Imaginarysy,_Atomicsy,
|
||||
extendedsy,compsy,_Boolsy,boolsy,_Complexsy,_Imaginarysy,_Atomicsy,
|
||||
structsy,unionsy,enumsy,typedef];
|
||||
|
||||
storageClassSpecifiers :=
|
||||
[typedefsy,externsy,staticsy,_Thread_localsy,autosy,registersy];
|
||||
[typedefsy,externsy,staticsy,_Thread_localsy,thread_localsy,autosy,registersy];
|
||||
|
||||
typeQualifiers :=
|
||||
[constsy,volatilesy,restrictsy,_Atomicsy];
|
||||
|
||||
functionSpecifiers := [inlinesy,_Noreturnsy,pascalsy,asmsy];
|
||||
|
||||
alignmentSpecifiers := [_Alignassy];
|
||||
alignmentSpecifiers := [_Alignassy,alignassy];
|
||||
|
||||
declarationSpecifiersElement := typeSpecifierStart + storageClassSpecifiers
|
||||
+ typeQualifiers + functionSpecifiers + alignmentSpecifiers;
|
||||
@ -4765,13 +4766,14 @@ declarationSpecifiersElement := typeSpecifierStart + storageClassSpecifiers
|
||||
specifierQualifierListElement :=
|
||||
typeSpecifierStart + typeQualifiers + alignmentSpecifiers + [pascalsy];
|
||||
|
||||
structDeclarationStart := specifierQualifierListElement + [_Static_assertsy];
|
||||
structDeclarationStart :=
|
||||
specifierQualifierListElement + [_Static_assertsy,static_assertsy];
|
||||
|
||||
topLevelDeclarationStart :=
|
||||
declarationSpecifiersElement + [ident,segmentsy,_Static_assertsy];
|
||||
topLevelDeclarationStart := declarationSpecifiersElement
|
||||
+ [ident,segmentsy,_Static_assertsy,static_assertsy];
|
||||
|
||||
localDeclarationStart :=
|
||||
declarationSpecifiersElement + [_Static_assertsy] - [asmsy];
|
||||
declarationSpecifiersElement + [_Static_assertsy,static_assertsy] - [asmsy];
|
||||
end; {InitParser}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user