mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-09-27 03:54:30 +00:00
Fix issue where a label with the same name as a typedef name was parsed as the beginning of a declaration.
This would lead to errors in programs like the following: int main(void) { typedef int x; x: ; } Even before support for mixed statements and declarations was introduced, this error could happen if the labeled statement was the first statement after the declarations in a block (as in the above example). Adding that support also allowed this error to happen with later statements in a block. The C4.2.4.1.CC test case was affected by this.
This commit is contained in:
parent
d6502c0719
commit
237af41e90
28
Parser.pas
28
Parser.pas
@ -3677,11 +3677,19 @@ procedure DoStatement;
|
|||||||
|
|
||||||
{ process a statement from a function }
|
{ process a statement from a function }
|
||||||
|
|
||||||
|
var
|
||||||
|
lToken: tokenType; {temporary copy of old token}
|
||||||
|
nToken: tokenType; {new token}
|
||||||
|
hasStatementNext: boolean; {is a stmt next within a compound stmt?}
|
||||||
|
lPrintMacroExpansions: boolean; {local copy of printMacroExpansions}
|
||||||
|
|
||||||
begin {DoStatement}
|
begin {DoStatement}
|
||||||
case statementList^.kind of
|
case statementList^.kind of
|
||||||
|
|
||||||
compoundSt: begin
|
compoundSt: begin
|
||||||
|
hasStatementNext := true;
|
||||||
if token.kind = rbracech then begin
|
if token.kind = rbracech then begin
|
||||||
|
hasStatementNext := false;
|
||||||
EndCompoundStatement;
|
EndCompoundStatement;
|
||||||
end {if}
|
end {if}
|
||||||
else if (statementList^.doingDeclaration or allowMixedDeclarations)
|
else if (statementList^.doingDeclaration or allowMixedDeclarations)
|
||||||
@ -3690,9 +3698,27 @@ case statementList^.kind of
|
|||||||
floatsy,doublesy,compsy,extendedsy,enumsy,
|
floatsy,doublesy,compsy,extendedsy,enumsy,
|
||||||
structsy,unionsy,typedef,voidsy,volatilesy,
|
structsy,unionsy,typedef,voidsy,volatilesy,
|
||||||
constsy])
|
constsy])
|
||||||
then
|
then begin
|
||||||
|
hasStatementNext := false;
|
||||||
|
if token.kind <> typedef then
|
||||||
DoDeclaration(false)
|
DoDeclaration(false)
|
||||||
else begin
|
else begin
|
||||||
|
lToken := token;
|
||||||
|
lPrintMacroExpansions := printMacroExpansions; {inhibit token echo}
|
||||||
|
printMacroExpansions := false;
|
||||||
|
NextToken;
|
||||||
|
printMacroExpansions := lPrintMacroExpansions;
|
||||||
|
nToken := token;
|
||||||
|
PutBackToken(nToken, false);
|
||||||
|
token := lToken;
|
||||||
|
if nToken.kind <> colonch then
|
||||||
|
DoDeclaration(false)
|
||||||
|
else
|
||||||
|
hasStatementNext := true;
|
||||||
|
end {else}
|
||||||
|
end; {else if}
|
||||||
|
|
||||||
|
if hasStatementNext then begin
|
||||||
if statementList^.doingDeclaration then begin
|
if statementList^.doingDeclaration then begin
|
||||||
statementList^.doingDeclaration := false;
|
statementList^.doingDeclaration := false;
|
||||||
if firstCompoundStatement then begin
|
if firstCompoundStatement then begin
|
||||||
|
Loading…
Reference in New Issue
Block a user