mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 10:49:09 +02:00
parent
0a73f141a4
commit
e787cb1ff3
@ -76,6 +76,7 @@ const
|
|||||||
nParserExpectedTypeButGot = 2049;
|
nParserExpectedTypeButGot = 2049;
|
||||||
nParserPropertyArgumentsCanNotHaveDefaultValues = 2050;
|
nParserPropertyArgumentsCanNotHaveDefaultValues = 2050;
|
||||||
nParserExpectedExternalClassName = 2051;
|
nParserExpectedExternalClassName = 2051;
|
||||||
|
nParserNoConstRangeAllowed = 2052;
|
||||||
|
|
||||||
// resourcestring patterns of messages
|
// resourcestring patterns of messages
|
||||||
resourcestring
|
resourcestring
|
||||||
@ -130,6 +131,7 @@ resourcestring
|
|||||||
SParserExpectedTypeButGot = 'Expected type, but got %s';
|
SParserExpectedTypeButGot = 'Expected type, but got %s';
|
||||||
SParserPropertyArgumentsCanNotHaveDefaultValues = 'Property arguments can not have default values';
|
SParserPropertyArgumentsCanNotHaveDefaultValues = 'Property arguments can not have default values';
|
||||||
SParserExpectedExternalClassName = 'Expected external class name';
|
SParserExpectedExternalClassName = 'Expected external class name';
|
||||||
|
SParserNoConstRangeAllowed = 'Const ranges are not allowed';
|
||||||
|
|
||||||
type
|
type
|
||||||
TPasScopeType = (
|
TPasScopeType = (
|
||||||
@ -3339,6 +3341,8 @@ begin
|
|||||||
ExpectToken(tkEqual);
|
ExpectToken(tkEqual);
|
||||||
NextToken;
|
NextToken;
|
||||||
Result.Expr:=DoParseConstValueExpression(Result);
|
Result.Expr:=DoParseConstValueExpression(Result);
|
||||||
|
if (Result.VarType=Nil) and (Result.Expr.Kind=pekRange) then
|
||||||
|
ParseExc(nParserNoConstRangeAllowed, SParserNoConstRangeAllowed );
|
||||||
UngetToken;
|
UngetToken;
|
||||||
CheckHint(Result,True);
|
CheckHint(Result,True);
|
||||||
ok:=true;
|
ok:=true;
|
||||||
|
@ -5,7 +5,7 @@ unit tconstparser;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, fpcunit, pastree, pscanner, tcbaseparser, testregistry;
|
Classes, SysUtils, fpcunit, pastree, pscanner, tcbaseparser, testregistry, pparser;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
{ TTestConstParser }
|
{ TTestConstParser }
|
||||||
@ -16,6 +16,7 @@ Type
|
|||||||
FExpr: TPasExpr;
|
FExpr: TPasExpr;
|
||||||
FHint : string;
|
FHint : string;
|
||||||
FTyped: String;
|
FTyped: String;
|
||||||
|
procedure DoParseConstUnTypedRange;
|
||||||
Protected
|
Protected
|
||||||
Function ParseConst(ASource : String) : TPasConst;
|
Function ParseConst(ASource : String) : TPasConst;
|
||||||
Procedure CheckExprNameKindClass(AKind : TPasExprKind; AClass : TClass);
|
Procedure CheckExprNameKindClass(AKind : TPasExprKind; AClass : TClass);
|
||||||
@ -78,6 +79,7 @@ Type
|
|||||||
Procedure TestRecordConst;
|
Procedure TestRecordConst;
|
||||||
Procedure TestArrayConst;
|
Procedure TestArrayConst;
|
||||||
Procedure TestRangeConst;
|
Procedure TestRangeConst;
|
||||||
|
Procedure TestRangeConstUnTyped;
|
||||||
Procedure TestArrayOfRangeConst;
|
Procedure TestArrayOfRangeConst;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -518,6 +520,17 @@ begin
|
|||||||
AssertExpression('Float const', TheExpr,pekNumber,'1');
|
AssertExpression('Float const', TheExpr,pekNumber,'1');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestConstParser.DoParseConstUnTypedRange;
|
||||||
|
|
||||||
|
begin
|
||||||
|
ParseConst('1..2');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestConstParser.TestRangeConstUnTyped;
|
||||||
|
begin
|
||||||
|
AssertException('Range const is not allowed',EParserError,@DoParseConstUnTypedRange);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestConstParser.TestArrayOfRangeConst;
|
procedure TTestConstParser.TestArrayOfRangeConst;
|
||||||
Var
|
Var
|
||||||
R : TArrayValues;
|
R : TArrayValues;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
<CommandLineParams Value="--suite=TTestExpressions.TestArrayAccess"/>
|
<CommandLineParams Value="--suite=TestHelperOnLiteral"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="1">
|
<RequiredPackages Count="1">
|
||||||
|
Loading…
Reference in New Issue
Block a user