mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-06 16:50:25 +02:00
* DFA now takes case-completeness into account (mantis #35598)
git-svn-id: trunk@42091 -
This commit is contained in:
parent
2ff391c25c
commit
7e51c5e856
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -12741,7 +12741,9 @@ tests/test/opt/tdfa15.pp svneol=native#text/pascal
|
|||||||
tests/test/opt/tdfa16.pp svneol=native#text/pascal
|
tests/test/opt/tdfa16.pp svneol=native#text/pascal
|
||||||
tests/test/opt/tdfa17.pp svneol=native#text/pascal
|
tests/test/opt/tdfa17.pp svneol=native#text/pascal
|
||||||
tests/test/opt/tdfa18.pp svneol=native#text/pascal
|
tests/test/opt/tdfa18.pp svneol=native#text/pascal
|
||||||
|
tests/test/opt/tdfa19.pp svneol=native#text/plain
|
||||||
tests/test/opt/tdfa2.pp svneol=native#text/pascal
|
tests/test/opt/tdfa2.pp svneol=native#text/pascal
|
||||||
|
tests/test/opt/tdfa20.pp svneol=native#text/plain
|
||||||
tests/test/opt/tdfa3.pp svneol=native#text/pascal
|
tests/test/opt/tdfa3.pp svneol=native#text/pascal
|
||||||
tests/test/opt/tdfa4.pp svneol=native#text/pascal
|
tests/test/opt/tdfa4.pp svneol=native#text/pascal
|
||||||
tests/test/opt/tdfa5.pp svneol=native#text/pascal
|
tests/test/opt/tdfa5.pp svneol=native#text/pascal
|
||||||
|
@ -53,7 +53,7 @@ unit optdfa;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
globtype,
|
globtype,constexp,
|
||||||
verbose,
|
verbose,
|
||||||
symconst,symdef,symsym,
|
symconst,symdef,symsym,
|
||||||
defutil,
|
defutil,
|
||||||
@ -225,6 +225,7 @@ unit optdfa;
|
|||||||
dfainfo : tdfainfo;
|
dfainfo : tdfainfo;
|
||||||
l : TDFASet;
|
l : TDFASet;
|
||||||
save: TDFASet;
|
save: TDFASet;
|
||||||
|
lv, hv: TConstExprInt;
|
||||||
i : longint;
|
i : longint;
|
||||||
counteruse_after_loop : boolean;
|
counteruse_after_loop : boolean;
|
||||||
begin
|
begin
|
||||||
@ -485,7 +486,16 @@ unit optdfa;
|
|||||||
if assigned(tcasenode(node).elseblock) then
|
if assigned(tcasenode(node).elseblock) then
|
||||||
DFASetIncludeSet(l,tcasenode(node).elseblock.optinfo^.life)
|
DFASetIncludeSet(l,tcasenode(node).elseblock.optinfo^.life)
|
||||||
else if assigned(node.successor) then
|
else if assigned(node.successor) then
|
||||||
DFASetIncludeSet(l,node.successor.optinfo^.life);
|
begin
|
||||||
|
if is_ordinal(tcasenode(node).left.resultdef) then
|
||||||
|
begin
|
||||||
|
getrange(tcasenode(node).left.resultdef,lv,hv);
|
||||||
|
if tcasenode(node).labelcoverage<(hv-lv) then
|
||||||
|
DFASetIncludeSet(l,node.successor.optinfo^.life);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
DFASetIncludeSet(l,node.successor.optinfo^.life);
|
||||||
|
end;
|
||||||
|
|
||||||
{ add use info from the "case" expression }
|
{ add use info from the "case" expression }
|
||||||
DFASetIncludeSet(l,tcasenode(node).optinfo^.use);
|
DFASetIncludeSet(l,tcasenode(node).optinfo^.use);
|
||||||
|
20
tests/test/opt/tdfa19.pp
Normal file
20
tests/test/opt/tdfa19.pp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{ %OPT=-Oodfa -vw -Sew }
|
||||||
|
{ %norun }
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
|
||||||
|
program project1;
|
||||||
|
|
||||||
|
type
|
||||||
|
trange=0..5;
|
||||||
|
|
||||||
|
function f(r: trange): longint;
|
||||||
|
begin
|
||||||
|
case r of
|
||||||
|
0..5: result:=r;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
writeln(f(2));
|
||||||
|
end.
|
22
tests/test/opt/tdfa20.pp
Normal file
22
tests/test/opt/tdfa20.pp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{ %OPT=-Oodfa -vw -Sew -vm6060 }
|
||||||
|
{ %FAIL }
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
|
||||||
|
program project1;
|
||||||
|
|
||||||
|
type
|
||||||
|
trange=0..5;
|
||||||
|
|
||||||
|
function f(r: trange): longint;
|
||||||
|
begin
|
||||||
|
{ must give a warning about unset function result; warning about incomplete
|
||||||
|
case statement is suppressed with -vm6060 }
|
||||||
|
case r of
|
||||||
|
0..4: result:=r;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
writeln(f(2));
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user