fcl-passrc: fixed unit implementation uses namespace as unit intf identifier

git-svn-id: trunk@46751 -
This commit is contained in:
Mattias Gaertner 2020-09-02 20:23:27 +00:00
parent 545ee82ec4
commit dd82f63c3f
2 changed files with 36 additions and 6 deletions

View File

@ -5672,17 +5672,21 @@ begin
ParentScope:=Scopes[ScopeCount-2];
if ParentScope is TPasSectionScope then
begin
// check unit interface and implementation duplicates
OlderIdentifier:=TPasSectionScope(ParentScope).FindLocalIdentifier(aName);
if IsGeneric then
OlderIdentifier:=SkipGenericTypes(OlderIdentifier,TypeParamCnt);
if OlderIdentifier<>nil then
begin
repeat
if IsGeneric then
OlderIdentifier:=SkipGenericTypes(OlderIdentifier,TypeParamCnt);
if OlderIdentifier=nil then break;
OlderEl:=OlderIdentifier.Element;
if (Identifier.Kind=pikSimple)
if (Identifier.Kind=pikNamespace)
or (OlderIdentifier.Kind=pikNamespace) then
else if (Identifier.Kind=pikSimple)
or (OlderIdentifier.Kind=pikSimple) then
RaiseMsg(20190818141630,nDuplicateIdentifier,sDuplicateIdentifier,
[aName,GetElementSourcePosStr(OlderEl)],El);
end;
OlderIdentifier:=OlderIdentifier.NextSameIdentifier;
until OlderIdentifier=nil;
end;
end;

View File

@ -373,6 +373,7 @@ type
Procedure TestUnit_DottedPrg;
Procedure TestUnit_DottedUnit;
Procedure TestUnit_DottedExpr;
Procedure TestUnit_DottedSystem;
Procedure TestUnit_DuplicateDottedUsesFail;
Procedure TestUnit_DuplicateUsesDiffName;
Procedure TestUnit_Unit1DotUnit2Fail;
@ -5975,6 +5976,31 @@ begin
ParseProgram;
end;
procedure TTestResolver.TestUnit_DottedSystem;
begin
AddModuleWithIntfImplSrc('System.SysUtils.pas',
LinesToStr([
'type TFlag = word;'
]),
''
);
AddModuleWithIntfImplSrc('UnitA.pas',
LinesToStr([
''
]),
LinesToStr([
'uses System.SysUtils;',
'type TSize = TFlag;',
'type TWidth = System.SysUtils.TFlag;',
'type TBird = System.integer;',
'type TEagle = integer;',
'']) );
StartProgram(true);
Add('uses UnitA;');
Add('begin');
ParseProgram;
end;
procedure TTestResolver.TestUnit_DuplicateDottedUsesFail;
begin
AddModuleWithIntfImplSrc('ns.unit2.pp',