mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 23:36:01 +02:00
codetools: read var postfix modifiers without first semicolon, bug #25543
git-svn-id: trunk@43751 -
This commit is contained in:
parent
3296df64f5
commit
f8d3895843
@ -201,9 +201,11 @@ type
|
||||
const Attr: TProcHeadAttributes): boolean;
|
||||
function ReadParamList(ExceptionOnError, Extract: boolean;
|
||||
const Attr: TProcHeadAttributes): boolean;
|
||||
// uses, requires, contains
|
||||
function ReadUsesSection(ExceptionOnError: boolean): boolean;
|
||||
function ReadRequiresSection(ExceptionOnError: boolean): boolean;
|
||||
function ReadContainsSection(ExceptionOnError: boolean): boolean;
|
||||
// terms
|
||||
function ReadSubRange(ExceptionOnError: boolean): boolean;
|
||||
function ReadTilBracketCloseOrUnexpected(ExceptionOnNotFound: boolean;
|
||||
Flags: TSkipBracketChecks): boolean;
|
||||
@ -3244,6 +3246,7 @@ end;
|
||||
|
||||
procedure TPascalParserTool.ReadVariableType;
|
||||
{ creates nodes for variable type
|
||||
CurPos will be on the last atom, on the semicolon or the atom in front of the 'end'
|
||||
|
||||
examples:
|
||||
|
||||
@ -3255,6 +3258,12 @@ procedure TPascalParserTool.ReadVariableType;
|
||||
a:b; external name 'string constant';
|
||||
a:b; cvar; external;
|
||||
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
|
||||
|
||||
@ -3264,12 +3273,14 @@ procedure TPascalParserTool.ReadVariableType;
|
||||
}
|
||||
var
|
||||
ParentNode: TCodeTreeNode;
|
||||
HasSemicolon: Boolean;
|
||||
begin
|
||||
ReadNextAtom;
|
||||
// type
|
||||
ParseType(CurPos.StartPos);
|
||||
|
||||
ParentNode:=CurNode.Parent;
|
||||
|
||||
// optional: absolute
|
||||
if (ParentNode.Desc=ctnVarSection) then begin
|
||||
if UpAtomIs('ABSOLUTE') then begin
|
||||
@ -3289,10 +3300,14 @@ begin
|
||||
// optional: hint modifier
|
||||
ReadHintModifiers;
|
||||
|
||||
// semicolon and postfix modifiers
|
||||
HasSemicolon:=false;
|
||||
if CurPos.Flag=cafSemicolon then begin
|
||||
// read ;
|
||||
HasSemicolon:=true;
|
||||
ReadNextAtom;
|
||||
end;
|
||||
|
||||
// postfix modifiers
|
||||
if UpAtomIs('CVAR') then begin
|
||||
// for example: 'var a: char; cvar;'
|
||||
ReadNextAtom;
|
||||
@ -3316,7 +3331,7 @@ begin
|
||||
or ((CurNode.Parent.Parent.Desc in (AllClassBaseSections+AllClassInterfaces))
|
||||
and Scanner.Values.IsDefined('CPUJVM')))
|
||||
and (UpAtomIs('PUBLIC') or UpAtomIs('EXPORT') or UpAtomIs('EXTERNAL')
|
||||
or UpAtomIs('WEAKEXTERNAL') or UpAtomIs('CVAR')) then
|
||||
or UpAtomIs('WEAKEXTERNAL')) then
|
||||
begin
|
||||
// examples:
|
||||
// a: b; public;
|
||||
@ -3350,11 +3365,11 @@ begin
|
||||
end;
|
||||
if CurPos.Flag<>cafSemicolon then
|
||||
SaveRaiseCharExpectedButAtomFound(';');
|
||||
end else
|
||||
UndoReadNextAtom;
|
||||
end else if CurPos.Flag=cafEND then begin
|
||||
UndoReadNextAtom;
|
||||
end else begin
|
||||
// no postfix modifier
|
||||
if not HasSemicolon then
|
||||
SaveRaiseCharExpectedButAtomFound(';');
|
||||
end;
|
||||
CurNode.EndPos:=CurPos.EndPos;
|
||||
|
Loading…
Reference in New Issue
Block a user