fcl-passrc: resolver: use same msg id as fpc for some hints

git-svn-id: trunk@38980 -
This commit is contained in:
Mattias Gaertner 2018-05-12 14:35:03 +00:00
parent d5372d7547
commit a445450486
4 changed files with 45 additions and 15 deletions

View File

@ -91,7 +91,7 @@ const
nCallingConventionMismatch = 3018; nCallingConventionMismatch = 3018;
nResultTypeMismatchExpectedButFound = 3019; nResultTypeMismatchExpectedButFound = 3019;
nFunctionHeaderMismatchForwardVarName = 3020; nFunctionHeaderMismatchForwardVarName = 3020;
nFunctionHidesIdentifier = 3021; nFunctionHidesIdentifier_NonVirtualMethod = 3021;
nNoMethodInAncestorToOverride = 3022; nNoMethodInAncestorToOverride = 3022;
nInheritedOnlyWorksInMethods = 3023; nInheritedOnlyWorksInMethods = 3023;
nInheritedNeedsAncestor = 3024; nInheritedNeedsAncestor = 3024;
@ -120,7 +120,7 @@ const
nExpectXArrayElementsButFoundY = 3047; nExpectXArrayElementsButFoundY = 3047;
nCannotCreateADescendantOfTheSealedXY = 3048; nCannotCreateADescendantOfTheSealedXY = 3048;
nAncestorIsNotExternal = 3049; nAncestorIsNotExternal = 3049;
nVirtualMethodXHasLowerVisibility = 3050; // FPC 3250 // free 3050
nExternalClassInstanceCannotAccessStaticX = 3051; nExternalClassInstanceCannotAccessStaticX = 3051;
nXModifierMismatchY = 3052; nXModifierMismatchY = 3052;
nSymbolCannotBePublished = 3053; nSymbolCannotBePublished = 3053;
@ -128,12 +128,12 @@ const
nTypeIdentifierExpected = 3055; nTypeIdentifierExpected = 3055;
nCannotNestAnonymousX = 3056; nCannotNestAnonymousX = 3056;
nFoundCallCandidateX = 3057; nFoundCallCandidateX = 3057;
nSymbolXIsNotPortable = 3058; // free 3058
nSymbolXIsExperimental = 3059; // free 3059
nSymbolXIsNotImplemented = 3060; // free 3060
nSymbolXBelongsToALibrary = 3061; // free 3061
nSymbolXIsDeprecated = 3062; // free 3062
nSymbolXIsDeprecatedY = 3063; // free 3063
nRangeCheckError = 3064; nRangeCheckError = 3064;
nHighRangeLimitLTLowRangeLimit = 3065; nHighRangeLimitLTLowRangeLimit = 3065;
nRangeCheckEvaluatingConstantsVMinMax = 3066; nRangeCheckEvaluatingConstantsVMinMax = 3066;
@ -150,7 +150,7 @@ const
nMethodHidesMethodOfBaseType = 3077; nMethodHidesMethodOfBaseType = 3077;
nContextExpectedXButFoundY = 3078; nContextExpectedXButFoundY = 3078;
nContextXInvalidY = 3079; nContextXInvalidY = 3079;
nConstructingClassXWithAbstractMethodY = 3080; // free 3080;
nXIsNotSupported = 3081; nXIsNotSupported = 3081;
nOperatorIsNotOverloadedAOpB = 3082; nOperatorIsNotOverloadedAOpB = 3082;
nIllegalQualifierAfter = 3084; nIllegalQualifierAfter = 3084;
@ -171,6 +171,17 @@ const
nMissingFieldsX = 3109; nMissingFieldsX = 3109;
nCantAssignValuesToConstVariable = 3110; nCantAssignValuesToConstVariable = 3110;
nIllegalAssignmentToForLoopVar = 3111; nIllegalAssignmentToForLoopVar = 3111;
nFunctionHidesIdentifier_NonProc = 3112;
// using same IDs as FPC
nVirtualMethodXHasLowerVisibility = 3250;
nConstructingClassXWithAbstractMethodY = 4046;
nSymbolXIsDeprecated = 5043;
nSymbolXBelongsToALibrary = 5065;
nSymbolXIsDeprecatedY = 5066;
nSymbolXIsNotPortable = 5076;
nSymbolXIsNotImplemented = 5078;
nSymbolXIsExperimental = 5079;
// resourcestring patterns of messages // resourcestring patterns of messages
resourcestring resourcestring
@ -194,7 +205,7 @@ resourcestring
sCallingConventionMismatch = 'Calling convention mismatch'; sCallingConventionMismatch = 'Calling convention mismatch';
sResultTypeMismatchExpectedButFound = 'Result type mismatch, expected %s, but found %s'; sResultTypeMismatchExpectedButFound = 'Result type mismatch, expected %s, but found %s';
sFunctionHeaderMismatchForwardVarName = 'function header "%s" doesn''t match forward : var name changes %s => %s'; sFunctionHeaderMismatchForwardVarName = 'function header "%s" doesn''t match forward : var name changes %s => %s';
sFunctionHidesIdentifier = 'function hides identifier at "%s"'; sFunctionHidesIdentifier = 'function hides identifier at "%s". Use overload or reintroduce';
sNoMethodInAncestorToOverride = 'There is no method in an ancestor class to be overridden "%s"'; sNoMethodInAncestorToOverride = 'There is no method in an ancestor class to be overridden "%s"';
sInheritedOnlyWorksInMethods = 'Inherited works only in methods'; sInheritedOnlyWorksInMethods = 'Inherited works only in methods';
sInheritedNeedsAncestor = 'inherited needs an ancestor'; sInheritedNeedsAncestor = 'inherited needs an ancestor';
@ -274,6 +285,7 @@ resourcestring
sMissingFieldsX = 'Missing fields: "%s"'; sMissingFieldsX = 'Missing fields: "%s"';
sCantAssignValuesToConstVariable = 'Can''t assign values to const variable'; sCantAssignValuesToConstVariable = 'Can''t assign values to const variable';
sIllegalAssignmentToForLoopVar = 'Illegal assignment to for-loop variable "%s"'; sIllegalAssignmentToForLoopVar = 'Illegal assignment to for-loop variable "%s"';
// sFunctionHidesIdentifier_NonProc = sFunctionHidesIdentifier
type type
{ TResolveData - base class for data stored in TPasElement.CustomData } { TResolveData - base class for data stored in TPasElement.CustomData }

View File

@ -4030,7 +4030,7 @@ begin
[El.Name,GetElementSourcePosStr(El)],Data^.Proc.ProcType) [El.Name,GetElementSourcePosStr(El)],Data^.Proc.ProcType)
else else
// give a hint // give a hint
LogMsg(20171118205344,mtHint,nFunctionHidesIdentifier,sFunctionHidesIdentifier, LogMsg(20171118205344,mtHint,nFunctionHidesIdentifier_NonProc,sFunctionHidesIdentifier,
[GetElementSourcePosStr(El)],Data^.Proc.ProcType); [GetElementSourcePosStr(El)],Data^.Proc.ProcType);
fopkMethod: fopkMethod:
// method hides a non proc // method hides a non proc
@ -4125,8 +4125,9 @@ begin
[Data^.Proc.Name,Proc.Parent.Name,GetElementSourcePosStr(Proc)],Data^.Proc.ProcType) [Data^.Proc.Name,Proc.Parent.Name,GetElementSourcePosStr(Proc)],Data^.Proc.ProcType)
else else
// Delphi/FPC do not give a message when hiding a non virtual method // Delphi/FPC do not give a message when hiding a non virtual method
// -> emit only an Info // -> emit Hint with other message id
LogMsg(20171118214523,mtInfo,nFunctionHidesIdentifier,sFunctionHidesIdentifier, LogMsg(20171118214523,mtHint,
nFunctionHidesIdentifier_NonVirtualMethod,sFunctionHidesIdentifier,
[GetElementSourcePosStr(Proc)],Data^.Proc.ProcType); [GetElementSourcePosStr(Proc)],Data^.Proc.ProcType);
Abort:=true; Abort:=true;
end; end;

View File

@ -48,6 +48,7 @@ uses
PasTree, PScanner, PasResolveEval, PasResolver; PasTree, PScanner, PasResolveEval, PasResolver;
const const
// use same IDs as fpc
nPAUnitNotUsed = 5023; nPAUnitNotUsed = 5023;
sPAUnitNotUsed = 'Unit "%s" not used in %s'; sPAUnitNotUsed = 'Unit "%s" not used in %s';
nPAParameterNotUsed = 5024; nPAParameterNotUsed = 5024;

View File

@ -643,6 +643,7 @@ type
Procedure TestClassInterface_MethodVirtualFail; Procedure TestClassInterface_MethodVirtualFail;
Procedure TestClassInterface_Overloads; Procedure TestClassInterface_Overloads;
Procedure TestClassInterface_OverloadHint; Procedure TestClassInterface_OverloadHint;
Procedure TestClassInterface_OverloadNoHint;
Procedure TestClassInterface_IntfListClassFail; Procedure TestClassInterface_IntfListClassFail;
Procedure TestClassInterface_IntfListDuplicateFail; Procedure TestClassInterface_IntfListDuplicateFail;
Procedure TestClassInterface_MissingMethodFail; Procedure TestClassInterface_MissingMethodFail;
@ -7733,7 +7734,8 @@ begin
'begin', 'begin',
' b.DoIt(3);']); ' b.DoIt(3);']);
ParseProgram; ParseProgram;
CheckResolverHint(mtInfo,nFunctionHidesIdentifier,'function hides identifier at "afile.pp(4,19)"'); CheckResolverHint(mtHint,nFunctionHidesIdentifier_NonVirtualMethod,
'function hides identifier at "afile.pp(4,19)". Use overload or reintroduce');
end; end;
procedure TTestResolver.TestClass_MethodReintroduce; procedure TTestResolver.TestClass_MethodReintroduce;
@ -10875,7 +10877,21 @@ begin
' end;', ' end;',
'begin']); 'begin']);
ParseProgram; ParseProgram;
CheckResolverHint(mtInfo,nFunctionHidesIdentifier,'function hides identifier at "afile.pp(4,19)"'); CheckResolverHint(mtHint,nFunctionHidesIdentifier_NonVirtualMethod,'function hides identifier at "afile.pp(4,19)". Use overload or reintroduce');
end;
procedure TTestResolver.TestClassInterface_OverloadNoHint;
begin
StartProgram(false);
Add([
'type',
' IUnknown = interface',
' procedure DoIt;',
' procedure DoIt(i: longint);',
' end;',
'begin']);
ParseProgram;
CheckResolverUnexpectedHints;
end; end;
procedure TTestResolver.TestClassInterface_IntfListClassFail; procedure TTestResolver.TestClassInterface_IntfListClassFail;