mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-23 06:49:49 +02:00
fcl-passrc: resolver: check library export function overload
git-svn-id: trunk@48118 -
This commit is contained in:
parent
f42f62565b
commit
3b0df17bd1
@ -9049,7 +9049,7 @@ begin
|
|||||||
CurEl:=nil;
|
CurEl:=nil;
|
||||||
if not SameText(RightStr(AttrName,length('Attribute')),'Attribute') then
|
if not SameText(RightStr(AttrName,length('Attribute')),'Attribute') then
|
||||||
begin
|
begin
|
||||||
// first search AttrName+'Attibute'
|
// first search AttrName+'Attribute'
|
||||||
CurEl:=FindFirstEl(AttrName+'Attribute',Data,NameExpr);
|
CurEl:=FindFirstEl(AttrName+'Attribute',Data,NameExpr);
|
||||||
end;
|
end;
|
||||||
// then search the name
|
// then search the name
|
||||||
@ -9164,12 +9164,14 @@ var
|
|||||||
FindData: TPRFindData;
|
FindData: TPRFindData;
|
||||||
Ref: TResolvedReference;
|
Ref: TResolvedReference;
|
||||||
ResolvedEl: TPasResolverResult;
|
ResolvedEl: TPasResolverResult;
|
||||||
|
Section: TPasSection;
|
||||||
|
Scope: TPasIdentifierScope;
|
||||||
|
ScopeIdent: TPasIdentifier;
|
||||||
begin
|
begin
|
||||||
Expr:=El.NameExpr;
|
Expr:=El.NameExpr;
|
||||||
if Expr<>nil then
|
if Expr<>nil then
|
||||||
begin
|
begin
|
||||||
ResolveExpr(Expr,rraRead);
|
ResolveExpr(Expr,rraRead);
|
||||||
//ResolveGlobalSymbol(Expr);
|
|
||||||
ComputeElement(Expr,ResolvedEl,[rcConstant]);
|
ComputeElement(Expr,ResolvedEl,[rcConstant]);
|
||||||
DeclEl:=ResolvedEl.IdentEl;
|
DeclEl:=ResolvedEl.IdentEl;
|
||||||
if DeclEl=nil then
|
if DeclEl=nil then
|
||||||
@ -9189,6 +9191,18 @@ begin
|
|||||||
CheckFoundElement(FindData,Ref);
|
CheckFoundElement(FindData,Ref);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if DeclEl is TPasProcedure then
|
||||||
|
begin
|
||||||
|
Section:=DeclEl.Parent as TPasSection;
|
||||||
|
Scope:=Section.CustomData as TPasIdentifierScope;
|
||||||
|
ScopeIdent:=Scope.FindLocalIdentifier(DeclEl.Name);
|
||||||
|
if (ScopeIdent=nil) then
|
||||||
|
RaiseNotYetImplemented(20210106103001,El,GetObjPath(DeclEl));
|
||||||
|
if ScopeIdent.NextSameIdentifier<>nil then
|
||||||
|
RaiseMsg(20210106103320,nCantDetermineWhichOverloadedFunctionToCall,
|
||||||
|
sCantDetermineWhichOverloadedFunctionToCall,[],El);
|
||||||
|
end;
|
||||||
|
|
||||||
// check index and name
|
// check index and name
|
||||||
CheckConstExpr(El.ExportIndex,[revkInt,revkUInt],'integer');
|
CheckConstExpr(El.ExportIndex,[revkInt,revkUInt],'integer');
|
||||||
CheckConstExpr(El.ExportName,[revkString,revkUnicodeString],'string');
|
CheckConstExpr(El.ExportName,[revkString,revkUnicodeString],'string');
|
||||||
@ -21318,7 +21332,7 @@ procedure TPasResolver.CheckFoundElement(
|
|||||||
// Call this method after finding an element by searching the scopes.
|
// Call this method after finding an element by searching the scopes.
|
||||||
|
|
||||||
function IsFieldInheritingConst(aRef: TResolvedReference): boolean;
|
function IsFieldInheritingConst(aRef: TResolvedReference): boolean;
|
||||||
// returns true of aRef is a TPasVariable that inherits its const from parent.
|
// returns true if aRef is a TPasVariable that inherits its const from parent.
|
||||||
// For example
|
// For example
|
||||||
// type TRecord = record
|
// type TRecord = record
|
||||||
// a: word; // inherits const
|
// a: word; // inherits const
|
||||||
@ -27564,6 +27578,21 @@ procedure TPasResolver.ComputeElement(El: TPasElement; out
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure ComputeExportSymbol(ExpSymbol: TPasExportSymbol);
|
||||||
|
var
|
||||||
|
Ref: TResolvedReference;
|
||||||
|
begin
|
||||||
|
if ExpSymbol.CustomData is TResolvedReference then
|
||||||
|
begin
|
||||||
|
Ref:=TResolvedReference(El.CustomData);
|
||||||
|
ComputeElement(Ref.Declaration,ResolvedEl,Flags+[rcNoImplicitProc],StartEl);
|
||||||
|
end
|
||||||
|
else if ExpSymbol.NameExpr<>nil then
|
||||||
|
ComputeElement(ExpSymbol.NameExpr,ResolvedEl,Flags,StartEl)
|
||||||
|
else
|
||||||
|
RaiseNotYetImplemented(20210106225512,ExpSymbol);
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
DeclEl: TPasElement;
|
DeclEl: TPasElement;
|
||||||
ElClass: TClass;
|
ElClass: TClass;
|
||||||
@ -27946,6 +27975,8 @@ begin
|
|||||||
ComputeSpecializeType(TPasSpecializeType(El))
|
ComputeSpecializeType(TPasSpecializeType(El))
|
||||||
else if ElClass=TInlineSpecializeExpr then
|
else if ElClass=TInlineSpecializeExpr then
|
||||||
ComputeElement(TInlineSpecializeExpr(El).NameExpr,ResolvedEl,Flags,StartEl)
|
ComputeElement(TInlineSpecializeExpr(El).NameExpr,ResolvedEl,Flags,StartEl)
|
||||||
|
else if ElClass=TPasExportSymbol then
|
||||||
|
ComputeExportSymbol(TPasExportSymbol(El))
|
||||||
else
|
else
|
||||||
RaiseNotYetImplemented(20160922163705,El);
|
RaiseNotYetImplemented(20160922163705,El);
|
||||||
{$IF defined(nodejs) and defined(VerbosePasResolver)}
|
{$IF defined(nodejs) and defined(VerbosePasResolver)}
|
||||||
|
@ -986,8 +986,8 @@ type
|
|||||||
Procedure TestLibrary_ExportFunc_IndexStringFail;
|
Procedure TestLibrary_ExportFunc_IndexStringFail;
|
||||||
Procedure TestLibrary_ExportVar; // ToDo
|
Procedure TestLibrary_ExportVar; // ToDo
|
||||||
Procedure TestLibrary_Initialization_Finalization;
|
Procedure TestLibrary_Initialization_Finalization;
|
||||||
Procedure TestLibrary_ExportFuncOverloadFail; // ToDo
|
Procedure TestLibrary_ExportFuncOverloadFail;
|
||||||
// ToDo Procedure TestLibrary_UnitExports;
|
Procedure TestLibrary_UnitExports;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LinesToStr(Args: array of const): string;
|
function LinesToStr(Args: array of const): string;
|
||||||
@ -18836,8 +18836,6 @@ end;
|
|||||||
|
|
||||||
procedure TTestResolver.TestLibrary_ExportFuncOverloadFail;
|
procedure TTestResolver.TestLibrary_ExportFuncOverloadFail;
|
||||||
begin
|
begin
|
||||||
exit;
|
|
||||||
|
|
||||||
StartLibrary(false);
|
StartLibrary(false);
|
||||||
Add([
|
Add([
|
||||||
'procedure Run(w: word); overload;',
|
'procedure Run(w: word); overload;',
|
||||||
@ -18850,7 +18848,24 @@ begin
|
|||||||
' Run,',
|
' Run,',
|
||||||
' afile.run;',
|
' afile.run;',
|
||||||
'begin']);
|
'begin']);
|
||||||
CheckResolverException('The symbol cannot be exported from a library',123);
|
CheckResolverException(sCantDetermineWhichOverloadedFunctionToCall,
|
||||||
|
nCantDetermineWhichOverloadedFunctionToCall);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestResolver.TestLibrary_UnitExports;
|
||||||
|
begin
|
||||||
|
StartUnit(false);
|
||||||
|
Add([
|
||||||
|
'interface' ,
|
||||||
|
'procedure Run;',
|
||||||
|
'implementation',
|
||||||
|
'procedure Run;',
|
||||||
|
'begin',
|
||||||
|
'end;',
|
||||||
|
'exports',
|
||||||
|
' Run;',
|
||||||
|
'']);
|
||||||
|
ParseUnit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
Loading…
Reference in New Issue
Block a user