Browse Source

* Fix visibility in records mixed with function/procedure

git-svn-id: trunk@29555 -
michael 10 years ago
parent
commit
7bb0b187a4

+ 3 - 4
packages/fcl-passrc/src/pparser.pp

@@ -669,7 +669,7 @@ begin
   Result:=IsModifier(S,PM);
   if result and (pm in [pmPublic,pmForward]) then
     begin
-    While (Parent<>Nil) and Not (Parent is TPasClassType) do
+    While (Parent<>Nil) and Not ((Parent is TPasClassType) or (Parent is TPasRecordType)) do
      Parent:=Parent.Parent;
     Result:=Not Assigned(Parent);
     end;
@@ -3640,14 +3640,13 @@ begin
       tkIdentifier :
         begin
         v:=visDefault;
-        If po_delphi in Scanner.Options then
+//        If (po_delphi in Scanner.Options) then
           if CheckVisibility(CurtokenString,v) then
             begin
             if not (v in [visPrivate,visPublic,visStrictPrivate]) then
               ParseExc(SParserInvalidRecordVisibility);
             NextToken;
-            if CurToken<>tkIdentifier then
-              ParseExc(SParserTypeSyntaxError);
+            Continue;
             end;
         ParseInlineVarDecl(ARec, ARec.Members, v, AEndToken=tkBraceClose);
         end;

+ 11 - 0
packages/fcl-passrc/tests/tctypeparser.pas

@@ -232,6 +232,7 @@ type
     Procedure TestTwoDeprecatedFieldsCombinedPlatform;
     Procedure TestFieldAndMethod;
     Procedure TestFieldAnd2Methods;
+    Procedure TestVisibilityAndMethods;
     Procedure TestNested;
     Procedure TestNestedDeprecated;
     Procedure TestNestedPlatform;
@@ -1818,6 +1819,16 @@ begin
   AssertEquals('Method 2 result type','Integer', P.FuncType.ResultEl.ResultType.Name);
 end;
 
+procedure TTestRecordTypeParser.TestVisibilityAndMethods;
+begin
+  ParseType('record '+slineBreak+
+    'private '+slineBreak+
+    'function something: integer; '+slineBreak+
+    'public '+slineBreak+
+    'x : integer; '+slineBreak+
+    'end',TPasRecordType,'');
+end;
+
 procedure TTestRecordTypeParser.TestNested;
 begin
   TestFields(['x : integer;','y : record','  z : integer;','end'],'',False);

+ 1 - 2
packages/fcl-passrc/tests/testpassrc.lpi

@@ -30,8 +30,7 @@
     <RunParams>
       <local>
         <FormatVersion Value="1"/>
-        <CommandLineParams Value="--suite=TTestClassType.TestConstProtected"/>
-        <LaunchingApplication Use="True"/>
+        <CommandLineParams Value="--suite=TTestRecordTypeParser.TestVisibilityAndMethods"/>
       </local>
     </RunParams>
     <RequiredPackages Count="1">