Browse Source

* leave parse_proc_head() (with some error recovery) if the interface could not be found instead of running straight into an access violation
+ added test

git-svn-id: trunk@35007 -

svenbarth 8 years ago
parent
commit
3f77ce3b12
3 changed files with 23 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 8 1
      compiler/pdecsub.pas
  3. 14 0
      tests/tbf/tb0253.pp

+ 1 - 0
.gitattributes

@@ -10419,6 +10419,7 @@ tests/tbf/tb0251.pp svneol=native#text/pascal
 tests/tbf/tb0252a.pp svneol=native#text/plain
 tests/tbf/tb0252a.pp svneol=native#text/plain
 tests/tbf/tb0252b.pp svneol=native#text/plain
 tests/tbf/tb0252b.pp svneol=native#text/plain
 tests/tbf/tb0252c.pp svneol=native#text/plain
 tests/tbf/tb0252c.pp svneol=native#text/plain
+tests/tbf/tb0253.pp svneol=native#text/pascal
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain

+ 8 - 1
compiler/pdecsub.pas

@@ -878,7 +878,14 @@ implementation
                   (ttypesym(srsym).typedef.typ=objectdef) then
                   (ttypesym(srsym).typedef.typ=objectdef) then
                  ImplIntf:=find_implemented_interface(tobjectdef(astruct),tobjectdef(ttypesym(srsym).typedef));
                  ImplIntf:=find_implemented_interface(tobjectdef(astruct),tobjectdef(ttypesym(srsym).typedef));
                if ImplIntf=nil then
                if ImplIntf=nil then
-                 Message(parser_e_interface_id_expected)
+                 begin
+                   Message(parser_e_interface_id_expected);
+                   { error recovery }
+                   consume(_ID);
+                   if try_to_consume(_EQ) then
+                     consume(_ID);
+                   exit;
+                 end
                else
                else
                  { in case of a generic or specialized interface we need to use the
                  { in case of a generic or specialized interface we need to use the
                    name of the def instead of the symbol, so that always the correct
                    name of the def instead of the symbol, so that always the correct

+ 14 - 0
tests/tbf/tb0253.pp

@@ -0,0 +1,14 @@
+{ %FAIL }
+
+program tb0253;
+
+{$mode objfpc}
+
+type
+  TTest = class(TObject, IInterface)
+    procedure Blubb.Bar = Foo;
+  end;
+
+begin
+
+end.