codetools: read var postfix modifiers without first semicolon, bug #25543

git-svn-id: trunk@43751 -
This commit is contained in:
mattias 2014-01-17 10:54:36 +00:00
parent 3296df64f5
commit f8d3895843

View File

@ -201,9 +201,11 @@ type
const Attr: TProcHeadAttributes): boolean; const Attr: TProcHeadAttributes): boolean;
function ReadParamList(ExceptionOnError, Extract: boolean; function ReadParamList(ExceptionOnError, Extract: boolean;
const Attr: TProcHeadAttributes): boolean; const Attr: TProcHeadAttributes): boolean;
// uses, requires, contains
function ReadUsesSection(ExceptionOnError: boolean): boolean; function ReadUsesSection(ExceptionOnError: boolean): boolean;
function ReadRequiresSection(ExceptionOnError: boolean): boolean; function ReadRequiresSection(ExceptionOnError: boolean): boolean;
function ReadContainsSection(ExceptionOnError: boolean): boolean; function ReadContainsSection(ExceptionOnError: boolean): boolean;
// terms
function ReadSubRange(ExceptionOnError: boolean): boolean; function ReadSubRange(ExceptionOnError: boolean): boolean;
function ReadTilBracketCloseOrUnexpected(ExceptionOnNotFound: boolean; function ReadTilBracketCloseOrUnexpected(ExceptionOnNotFound: boolean;
Flags: TSkipBracketChecks): boolean; Flags: TSkipBracketChecks): boolean;
@ -3244,6 +3246,7 @@ end;
procedure TPascalParserTool.ReadVariableType; procedure TPascalParserTool.ReadVariableType;
{ creates nodes for variable type { creates nodes for variable type
CurPos will be on the last atom, on the semicolon or the atom in front of the 'end'
examples: examples:
@ -3255,6 +3258,12 @@ procedure TPascalParserTool.ReadVariableType;
a:b; external name 'string constant'; a:b; external name 'string constant';
a:b; cvar; external; a:b; cvar; external;
a:b; external 'library' name 'avar'; a:b; external 'library' name 'avar';
SomeVar : PChar External 'some_lib' Name 'somevar';
SomeOtherProgramHasAccessToThisVar : Integer Public Name 'somevar2';
SomeOtherVar : Word Public;
SomeOtherOtherVar : LongInt External Name 'somevar3';
somevar4 : Byte External;
somevar5 : Integer External 'some_lib';
implementation implementation
@ -3264,12 +3273,14 @@ procedure TPascalParserTool.ReadVariableType;
} }
var var
ParentNode: TCodeTreeNode; ParentNode: TCodeTreeNode;
HasSemicolon: Boolean;
begin begin
ReadNextAtom; ReadNextAtom;
// type // type
ParseType(CurPos.StartPos); ParseType(CurPos.StartPos);
ParentNode:=CurNode.Parent; ParentNode:=CurNode.Parent;
// optional: absolute // optional: absolute
if (ParentNode.Desc=ctnVarSection) then begin if (ParentNode.Desc=ctnVarSection) then begin
if UpAtomIs('ABSOLUTE') then begin if UpAtomIs('ABSOLUTE') then begin
@ -3289,10 +3300,14 @@ begin
// optional: hint modifier // optional: hint modifier
ReadHintModifiers; ReadHintModifiers;
// semicolon and postfix modifiers HasSemicolon:=false;
if CurPos.Flag=cafSemicolon then begin if CurPos.Flag=cafSemicolon then begin
// read ; // read ;
HasSemicolon:=true;
ReadNextAtom; ReadNextAtom;
end;
// postfix modifiers
if UpAtomIs('CVAR') then begin if UpAtomIs('CVAR') then begin
// for example: 'var a: char; cvar;' // for example: 'var a: char; cvar;'
ReadNextAtom; ReadNextAtom;
@ -3316,7 +3331,7 @@ begin
or ((CurNode.Parent.Parent.Desc in (AllClassBaseSections+AllClassInterfaces)) or ((CurNode.Parent.Parent.Desc in (AllClassBaseSections+AllClassInterfaces))
and Scanner.Values.IsDefined('CPUJVM'))) and Scanner.Values.IsDefined('CPUJVM')))
and (UpAtomIs('PUBLIC') or UpAtomIs('EXPORT') or UpAtomIs('EXTERNAL') and (UpAtomIs('PUBLIC') or UpAtomIs('EXPORT') or UpAtomIs('EXTERNAL')
or UpAtomIs('WEAKEXTERNAL') or UpAtomIs('CVAR')) then or UpAtomIs('WEAKEXTERNAL')) then
begin begin
// examples: // examples:
// a: b; public; // a: b; public;
@ -3350,11 +3365,11 @@ begin
end; end;
if CurPos.Flag<>cafSemicolon then if CurPos.Flag<>cafSemicolon then
SaveRaiseCharExpectedButAtomFound(';'); SaveRaiseCharExpectedButAtomFound(';');
end else
UndoReadNextAtom;
end else if CurPos.Flag=cafEND then begin end else if CurPos.Flag=cafEND then begin
UndoReadNextAtom; UndoReadNextAtom;
end else begin end else begin
// no postfix modifier
if not HasSemicolon then
SaveRaiseCharExpectedButAtomFound(';'); SaveRaiseCharExpectedButAtomFound(';');
end; end;
CurNode.EndPos:=CurPos.EndPos; CurNode.EndPos:=CurPos.EndPos;