Browse Source

fcl-passrc: less hints

mattias 2 years ago
parent
commit
f3c94ccbce
2 changed files with 22 additions and 19 deletions
  1. 2 1
      packages/fcl-passrc/src/fcl-passrc.inc
  2. 20 18
      packages/fcl-passrc/src/pparser.pp

+ 2 - 1
packages/fcl-passrc/src/fcl-passrc.inc

@@ -18,6 +18,7 @@
 {$ENDIF}
 
 {$IF FPC_FULLVERSION>30100}
-  {$warn 6058 off} // cannot inline
+  {$warn 6058 off : cannot inline}
+  {$WARN 6018 off : Unreachable code}
 {$ENDIF}
 

+ 20 - 18
packages/fcl-passrc/src/pparser.pp

@@ -948,6 +948,7 @@ end;
 
 function TPasTreeContainer.HandleResultOnError(aElement: TPasElement): Boolean;
 begin
+  if aElement=nil then ;
   Result:=True;
 end;
 
@@ -1487,8 +1488,6 @@ function TPasParser.TryErrorRecovery(const aContext: TRecoveryContext): boolean;
 
 var
   StopAt : TTokens;
-  tk : TToken;
-
 begin
   Inc(FErrorCount);
   Result:=FErrorCount<FMaxErrorCount;
@@ -5978,23 +5977,26 @@ begin
   Scanner.SetNonToken(tkobjccategory);
   Scanner.SetNonToken(tkobjcprotocol);
   Scanner.SetNonToken(tkobjcclass);
-  repeat
-    NextToken;
-//    writeln('TPasParser.ParseProcBeginBlock ',curtokenstring);
-    if CurToken=tkend then
-      break
-    else if CurToken<>tkSemiColon then
-    begin
-      UngetToken;
-      ParseStatement(BeginBlock,SubBlock);
-      if SubBlock=nil then
-        ExpectToken(tkend);
-    end;
-  until false;
+  try
+    repeat
+      NextToken;
+  //    writeln('TPasParser.ParseProcBeginBlock ',curtokenstring);
+      if CurToken=tkend then
+        break
+      else if CurToken<>tkSemiColon then
+      begin
+        UngetToken;
+        ParseStatement(BeginBlock,SubBlock);
+        if SubBlock=nil then
+          ExpectToken(tkend);
+      end;
+    until false;
+  finally
+    Scanner.UnSetNonToken(tkobjccategory);
+    Scanner.UnSetNonToken(tkobjcprotocol);
+    Scanner.UnSetNonToken(tkobjcclass);
+  end;
   // A declaration can follow...
-  Scanner.UnSetNonToken(tkobjccategory);
-  Scanner.UnSetNonToken(tkobjcprotocol);
-  Scanner.UnSetNonToken(tkobjcclass);
   Proc:=Parent.Parent as TPasProcedure;
   if Proc.GetProcTypeEnum in [ptAnonymousProcedure,ptAnonymousFunction] then
     NextToken