From 44aba04214473bc2dffb2cb2c22b07ef54d471cc Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 20 Feb 2018 17:36:15 +0000 Subject: [PATCH] codetools: parse built-in function concat in constant, issue #33201 git-svn-id: branches/fixes_1_8@57340 - --- components/codetools/pascalparsertool.pas | 9 ++++++--- components/codetools/tests/testpascalparser.pas | 11 +++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index a674a606c3..ba7d5c77aa 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -1699,6 +1699,7 @@ function TPascalParserTool.ReadTilProcedureHeadEnd( external; external ; external name delayed; + external name concat('',''); external name ; external index ; [alias: ] @@ -1970,10 +1971,12 @@ begin end; if CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen] then begin - // type cast or constant array + // type cast or constant array or built-in function BracketType:=CurPos.Flag; - if not Extract then ReadNextAtom else ExtractNextAtom(true,Attr); - if not ReadConstant(ExceptionOnError,Extract,Attr) then exit; + repeat + if not Extract then ReadNextAtom else ExtractNextAtom(true,Attr); + if not ReadConstant(ExceptionOnError,Extract,Attr) then exit; + until CurPos.Flag<>cafComma; if (BracketType=cafRoundBracketOpen) and (CurPos.Flag<>cafRoundBracketClose) then if ExceptionOnError then diff --git a/components/codetools/tests/testpascalparser.pas b/components/codetools/tests/testpascalparser.pas index c4041f3752..928bcc2ad6 100644 --- a/components/codetools/tests/testpascalparser.pas +++ b/components/codetools/tests/testpascalparser.pas @@ -34,6 +34,7 @@ type property Code: TCodeBuffer read FCode; published procedure TestRecord_ClassOperators; + procedure TestParseExternalConcat; end; implementation @@ -155,6 +156,16 @@ begin ParseModule; end; +procedure TTestPascalParser.TestParseExternalConcat; +begin + Add([ + 'program test1;', + '{$mode objfpc}', + 'procedure foo; cdecl; external name concat(''foo'', ''bar'');', + 'begin']); + ParseModule; +end; + initialization AddToPascalTestSuite(TTestPascalParser);