Browse Source

compiler: don't set a structure to routine if it accidentally match some (bug #0018452)

git-svn-id: trunk@16747 -
paul 14 years ago
parent
commit
f9f316ac45
1 changed files with 16 additions and 8 deletions
  1. 16 8
      compiler/pdecsub.pas

+ 16 - 8
compiler/pdecsub.pas

@@ -915,9 +915,8 @@ implementation
                    (ttypesym(srsym).typedef.typ in [objectdef,recorddef]) then
                 begin
                   astruct:=tabstractrecorddef(ttypesym(srsym).typedef);
-                  if (df_generic in astruct.defoptions) then
+                  if (df_generic in astruct.defoptions) and try_to_consume(_LT) then
                     begin
-                      consume(_LT);
                       ok:=true;
                       i:=0;
                       repeat
@@ -954,13 +953,22 @@ implementation
                       consume(_GT);
                     end
                   else
-                  if try_to_consume(_LT) then
+                  if (df_generic in astruct.defoptions) and (token=_POINT) then
                     begin
-                      Message(type_e_type_parameters_are_not_allowed_here);
-                      repeat
-                        consume(_ID);
-                      until not try_to_consume(_COMMA);
-                      consume(_GT);
+                      Message1(type_e_generic_declaration_does_not_match,astruct.RttiName);
+                    end
+                  else
+                    begin
+                      { not a method. routine name just accidentally match some structure name }
+                      astruct:=nil;
+                      if try_to_consume(_LT) then
+                        begin
+                          Message(type_e_type_parameters_are_not_allowed_here);
+                          repeat
+                            consume(_ID);
+                          until not try_to_consume(_COMMA);
+                          consume(_GT);
+                        end;
                     end;
                 end;
               end;