mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-21 21:32:00 +00:00
Add a new flag to control whether mixed declarations are allowed and C99 scope rules are used.
#pragma ignore bit 4 (a value of 16) now controls these. It is on by default (allowing them), but turning it off will restore the C89 rules.
This commit is contained in:
parent
2be0ef0de5
commit
275e1f080b
@ -864,7 +864,8 @@ procedure EndInclude {chPtr: ptr};
|
||||
WriteByte(ord(skipIllegalTokens)
|
||||
| (ord(allowLongIntChar) << 1)
|
||||
| (ord(allowTokensAfterEndif) << 2)
|
||||
| (ord(allowSlashSlashComments) << 3));
|
||||
| (ord(allowSlashSlashComments) << 3)
|
||||
| (ord(allowMixedDeclarations) << 4));
|
||||
|
||||
p_segment: begin
|
||||
for i := 1 to 10 do begin
|
||||
@ -1499,6 +1500,8 @@ var
|
||||
allowLongIntChar := odd(i >> 1);
|
||||
allowTokensAfterEndif := odd(i >> 2);
|
||||
allowSlashSlashComments := odd(i >> 3);
|
||||
allowMixedDeclarations := odd(i >> 4);
|
||||
c99Scope := allowMixedDeclarations;
|
||||
end;
|
||||
|
||||
p_segment: begin
|
||||
|
@ -81,8 +81,6 @@ implementation
|
||||
|
||||
const
|
||||
maxBitField = 32; {max # of bits in a bit field}
|
||||
allowMixedDeclarations = true;
|
||||
c99Scope = true;
|
||||
|
||||
type
|
||||
|
||||
|
14
Scanner.pas
14
Scanner.pas
@ -85,6 +85,9 @@ var
|
||||
allowSlashSlashComments: boolean; {allow // comments?}
|
||||
allowTokensAfterEndif: boolean; {allow tokens after #endif?}
|
||||
skipIllegalTokens: boolean; {skip flagging illegal tokens in skipped code?}
|
||||
{Note: The following two are set together}
|
||||
allowMixedDeclarations: boolean; {allow mixed declarations & stmts (C99)?}
|
||||
c99Scope: boolean; {follow C99 rules for block scopes?}
|
||||
|
||||
{---------------------------------------------------------------}
|
||||
|
||||
@ -613,6 +616,7 @@ if list or (numErr <> 0) then begin
|
||||
123: msg := @'array element type may not be an incomplete or function type';
|
||||
124: msg := @'invalid format string';
|
||||
125: msg := @'format string is not a string literal';
|
||||
126: msg := @'scope rules may not be changed within a function';
|
||||
otherwise: Error(57);
|
||||
end; {case}
|
||||
writeln(msg^);
|
||||
@ -2792,6 +2796,7 @@ if ch in ['a','d','e','i','l','p','u','w'] then begin
|
||||
{ 2 - allow long int character constants }
|
||||
{ 4 - allow tokens after #endif }
|
||||
{ 8 - allow // comments }
|
||||
{ 16 - allow mixed decls & use C99 scope rules }
|
||||
FlagPragmas(p_ignore);
|
||||
NumericDirective;
|
||||
val := long(expressionValue).lsw;
|
||||
@ -2799,6 +2804,13 @@ if ch in ['a','d','e','i','l','p','u','w'] then begin
|
||||
allowLongIntChar := odd(val >> 1);
|
||||
allowTokensAfterEndif := odd(val >> 2);
|
||||
allowSlashSlashComments := odd(val >> 3);
|
||||
allowMixedDeclarations := odd(val >> 4);
|
||||
if allowMixedDeclarations <> c99Scope then begin
|
||||
if doingFunction then
|
||||
Error(126)
|
||||
else
|
||||
c99Scope := allowMixedDeclarations;
|
||||
end; {if}
|
||||
if token.kind <> eolsy then
|
||||
Error(11);
|
||||
end {else if}
|
||||
@ -3371,6 +3383,8 @@ skipIllegalTokens := false; {flag illegal tokens in skipped code}
|
||||
allowLongIntChar := false; {allow long int char constants}
|
||||
allowTokensAfterEndif := false; {allow tokens after #endif}
|
||||
allowSlashSlashComments := true; {allow // comments}
|
||||
allowMixedDeclarations := true; {allow mixed declarations & stmts (C99)}
|
||||
c99Scope := true; {follow C99 rules for block scopes}
|
||||
foundFunction := false; {no functions found so far}
|
||||
fileList := nil; {no included files}
|
||||
gettingFileName := false; {not in GetFileName}
|
||||
|
Loading…
x
Reference in New Issue
Block a user