Ignore:
Timestamp:
Jul 17, 2012, 10:54:18 AM (12 years ago)
Author:
chronos
Message:
  • Fixed: Procedure/function header and body not paired properly.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/Analyze/UAnalyzerPascal.pas

    r62 r63  
    7676  SUnitNotFound = 'Unit "%s" not found.';
    7777  SFunctionNotDeclared = 'Function "%s" not declared.';
     78  SFunctionRedefinition = 'Function "%s" redefined.';
    7879  SUnknownProcName = 'Unknown proc name "%s".';
    7980  SUnknownModuleType = 'Unknown module name "%s".';
     
    703704      end;
    704705    end else begin
    705       // Create new function
    706       UseFunction := TFunction.Create;
    707       UseFunction.Parent := SourceCode.Parent;
    708       UseFunction.Name := UseName;
    709       UseFunction.FunctionType := FunctionType;
    710       UseFunction.Exported := Exported;
    711       Add(UseFunction);
    712       UseFunction.Parent.Order.Add(UseFunction);
    713       ValidParams := False;
     706      UseFunction := SourceCode.Search(UseName, True);
     707      if not Assigned(UseFunction) then begin
     708        // Create new function
     709        UseFunction := TFunction.Create;
     710        UseFunction.Parent := SourceCode.Parent;
     711        UseFunction.Name := UseName;
     712        UseFunction.FunctionType := FunctionType;
     713        UseFunction.Exported := Exported;
     714        Add(UseFunction);
     715        UseFunction.Parent.Order.Add(UseFunction);
     716        ValidParams := False;
     717      end else begin
     718        if not UseFunction.BodyLoaded then UseFunction.BodyLoaded := True
     719          else begin
     720            ErrorMessage(SFunctionRedefinition, [UseName]);
     721            Exit;
     722          end;
     723      end;
    714724    end;
    715725    with UseFunction do begin
Note: See TracChangeset for help on using the changeset viewer.