From de408de69e08fa9d4e22439bbae5d86dc5a0c3e9 Mon Sep 17 00:00:00 2001 From: juha Date: Sun, 15 Mar 2020 17:55:43 +0000 Subject: [PATCH] Codetools: Support ArrayToDynArray and other missing modeswitches. Issue #36796. git-svn-id: trunk@62768 - --- components/codetools/finddeclarationtool.pas | 6 +++--- components/codetools/linkscanner.pas | 16 ++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 1c0bc8be18..2cdadee03f 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -1777,7 +1777,7 @@ procedure TFDHelpersList.AddFromList(const Tool: TFindDeclarationTool; FromNode: TFDHelpersListItem; begin FromNode := TFDHelpersListItem(ANode.Data); - if (Kind=fdhlkDelphiHelper) and not (msMultiHelpers in Tool.Scanner.CompilerModeSwitches) then + if (Kind=fdhlkDelphiHelper) and not (cmsMultiHelpers in Tool.Scanner.CompilerModeSwitches) then if FTree.FindKey(FromNode, @CompareHelpersList) <> nil then Exit(nil); //FPC & Delphi don't support duplicate class helpers! Result := TFDHelpersListItem.Create; @@ -1841,7 +1841,7 @@ begin if ExprType.Desc in xtAllIdentTypes then begin - if (Kind=fdhlkDelphiHelper) and not (msMultiHelpers in Tool.Scanner.CompilerModeSwitches) then begin + if (Kind=fdhlkDelphiHelper) and not (cmsMultiHelpers in Tool.Scanner.CompilerModeSwitches) then begin // class/type/record helpers only allow one helper per class OldKey := FTree.FindKey(@ExprType, @CompareHelpersListExprType); if OldKey <> nil then @@ -4520,7 +4520,7 @@ var finally Params.Flags := OldFlags; end; - until ((HelperKind=fdhlkDelphiHelper) and not (msMultiHelpers in Params.StartTool.Scanner.CompilerModeSwitches)) + until ((HelperKind=fdhlkDelphiHelper) and not (cmsMultiHelpers in Params.StartTool.Scanner.CompilerModeSwitches)) or (not Helpers.GetNext(HelperContext,HelperIterator)); //debugln(['SearchInHelpers END']); end; diff --git a/components/codetools/linkscanner.pas b/components/codetools/linkscanner.pas index 97270e3065..1098d4e35f 100644 --- a/components/codetools/linkscanner.pas +++ b/components/codetools/linkscanner.pas @@ -213,19 +213,21 @@ type ansistring; similarly, char becomes unicodechar rather than ansichar } cmsTypeHelpers, { allows the declaration of "type helper" (non-Delphi) or "record helper" (Delphi) for primitive types } - cmsClosures, { Anonymous methods } + cmsClosures, { Anonymous methods } // not in tmodeswitch / globtype.pas !!! cmsCBlocks, { support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension) } cmsISOlike_IO, { I/O as it required by an ISO compatible compiler } cmsISOLike_Program_Para, { program parameters as it required by an ISO compatible compiler } cmsISOLike_Mod, { mod operation as it is required by an iso compatible compiler } cmsArrayOperators, { use Delphi compatible array operators instead of custom ones ("+") } + cmsMultiHelpers, { helpers can appear in multiple scopes simultaneously } + cmsArray2dynarray, { regular arrays can be implicitly converted to dynamic arrays } + cmsPrefixedAttributes, { enable attributes that are defined before the type they belong to } + // not yet in FPC, supported by pas2js: - cmsPrefixedAttributes, { allow Delphi attributes, disable FPC [] proc modifier } cmsExternalClass, { pas2js: allow class external [pkgname] name [symbol] } cmsIgnoreAttributes, { pas2js: ignore attributes } cmsOmitRTTI, { pas2js: treat class section 'published' as 'public' and typeinfo does not work on symbols declared with this switch } - msMultiHelpers, { off=only one helper per type, on=all } - msImplicitFunctionSpecialization { infer types on calls of generic functions } + cmsImplicitFunctionSpecialization { infer types on calls of generic functions } ); TCompilerModeSwitches = set of TCompilerModeSwitch; const @@ -303,17 +305,19 @@ const 'FINALFIELDS', 'UNICODESTRINGS', 'TYPEHELPERS', - 'CLOSURES', + 'CLOSURES', // not in tmodeswitch / globtype.pas 'CBLOCKS', 'ISOIO', 'ISOPROGRAMPARAS', 'ISOMOD', 'ARRAYOPERATORS', + 'MULTIHELPERS', + 'ARRAYTODYNARRAY', 'PREFIXEDATTRIBUTES', + // not yet in FPC, supported by pas2js: 'EXTERNALCLASS', 'IGNOREATTRIBUTES', 'OMITRTTI', - 'MULTIHELPERS', 'IMPLICITFUNCTIONSPECIALIZATION' );