code flow analysis for "Warning: Function result does not seem to be set" is faulty.
Original Reporter info from Mantis: Thorsten Engler
-
Reporter name: Thorsten Engler
Original Reporter info from Mantis: Thorsten Engler
- Reporter name: Thorsten Engler
Description:
program FunctionResultAnalysisWrong;
{$IFDEF FPC}
{$mode delphi}
{$ENDIF}
uses
SysUtils;
function Test1: Integer;
begin
raise Exception.Create('');
end; {should NOT generate "Warning: Function result does not seem to be set" (doesn't in delphi, does in FPC) }
function Test2: Integer;
begin
if Test1 > 0 then
raise Exception.Create('')
else
raise Exception.Create('');
end; {should NOT generate "Warning: Function result does not seem to be set" (doesn't in delphi, does in FPC) }
function Test3: Integer;
begin
if Test2 > 0 then
raise Exception.Create('')
end; {SHOULD generate "Warning: Function result does not seem to be set", and does in both delphi and FPC}
function Test4: Integer;
begin
if Test3 > 0 then
raise Exception.Create('')
else
Result := 0;
end; {should NOT generate "Warning: Function result does not seem to be set" (doesn't in delphi and FPC) }
function Test5: Integer;
begin
if Test4 > 0 then
Result := 0;
end; {SHOULD generate "Warning: Function result does not seem to be set", does in delphi, not in FPC }
begin
Test5;
end.
Additional information:
The correct behavior is the one from delphi:
[Pascal Warning] IE2006111510.dpr(27): W1035 Return value of function 'Test3' might be undefined
[Pascal Warning] IE2006111510.dpr(41): W1035 Return value of function 'Test5' might be undefined
Mantis conversion info:
- Mantis ID: 8151
- Version: 2.2.0
- Fixed in version: 2.4.0
- Fixed in revision: 11624 (#1c0bd054)