* fix unreachable code check for repeat loop

This commit is contained in:
peter 2005-01-16 14:44:03 +00:00
parent 9ba429a6e2
commit d5091e1817
3 changed files with 64 additions and 45 deletions

View File

@ -648,7 +648,7 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 37811;
MsgTxtSize = 38002;
MsgIdxMax : array[1..20] of longint=(
18,68,213,59,57,46,100,20,35,60,

View File

@ -1,7 +1,7 @@
{$ifdef Delphi}
const msgtxt : array[0..000157] of string[240]=(
const msgtxt : array[0..000158] of string[240]=(
{$else Delphi}
const msgtxt : array[0..000157,1..240] of char=(
const msgtxt : array[0..000158,1..240] of char=(
{$endif Delphi}
'01000_T_Compiler: $1'#000+
'01001_D_Compiler OS: $1'#000+
@ -833,88 +833,92 @@ const msgtxt : array[0..000157,1..240] of char=(
'**2Sc_supports operators like C (*=,+=,/= and -=)'#010+
'**2Sa_include assertion code.'#010+
'**2Sd_same as -Mdelphi'#010+
'**2Se<x>_compiler stops after the <x> errors (default is 1)'#010+
'**2Se<x>_error options. <x> is a combination of the following:'#010+
'**3*_<n> : compiler stops afte','r the <n> errors (default is 1)'#010+
'**3*_w : compiler stops also after warnings'#010+
'**3*_n : compiler stops also after notes'#010+
'**3*_h : compiler stops also after hints'#010+
'**2Sg_allow LABEL and GOTO'#010+
'**2Sh_','Use ansistrings'#010+
'**2Sh_Use ansistrings'#010+
'**2Si_support C++ styled INLINE'#010+
'**2SI<x>_set interface style to <x>'#010+
'*','*2SI<x>_set interface style to <x>'#010+
'**3SIcom_COM compatible interface (default)'#010+
'**3SIcorba_CORBA compatible interface'#010+
'**2Sm_support macros like C (global)'#010+
'**2So_same as -Mtp'#010+
'**2Sp_same as -Mgp','c'#010+
'**2Ss_constructor name must be init (destructor must be done)'#010+
'**2Sp_same as -Mgpc'#010+
'**2Ss_constructor name must be init (destructor',' must be done)'#010+
'**2St_allow static keyword in objects'#010+
'**1s_don'#039't call assembler and linker'#010+
'**2sh_Generate script to link on host'#010+
'**2st_Generate script to link on target'#010+
'**2sr_Skip register all','ocation phase (use with -alr)'#010+
'**1T<x>_Target operating system:'#010+
'**2sr_Skip register allocation phase (use with -alr)'#010+
'**1T<x>_Target oper','ating system:'#010+
'3*2Temx_OS/2 via EMX (including EMX/RSX extender)'#010+
'3*2Tfreebsd_FreeBSD'#010+
'3*2Tgo32v2_Version 2 of DJ Delorie DOS extender'#010+
'3*2Tlinux_Linux'#010+
'3*2Tnetbsd_NetBSD'#010+
'3*2Tnetware_Novell Netwar','e Module (clib)'#010+
'3*2Tnetwlibc_Novell Netware Module (libc)'#010+
'3*2Tnetware_Novell Netware Module (clib)'#010+
'3*2Tnetwlibc_Novell Netware Modul','e (libc)'#010+
'3*2Topenbsd_OpenBSD'#010+
'3*2Tos2_OS/2 / eComStation'#010+
'3*2Tsunos_SunOS/Solaris'#010+
'3*2Twatcom_Watcom compatible DOS extender'#010+
'3*2Twdosx_WDOSX DOS extender'#010+
'3*2Twin32_Windows 32 Bit'#010+
'4*2Tlinux_Linux',#010+
'4*2Tlinux_Linux'#010+
'6*2Tamiga_Commodore Amiga'#010+
'6*2Tatari_Atari ST/STe/TT'#010+
'6*2Tatari_Atari ST/STe','/TT'#010+
'6*2Tlinux_Linux-68k'#010+
'6*2Tmacos_Macintosh m68k (not supported)'#010+
'6*2Tpalmos_PalmOS'#010+
'A*2Tlinux_Linux'#010+
'P*2Tdarwin_Darwin and MacOS X on PowerPC'#010+
'P*2Tlinux_Linux on PowerPC'#010+
'P*2Tmacos_MacOS (classic',') on PowerPC'#010+
'P*2Tmacos_MacOS (classic) on PowerPC'#010+
'P*2Tmorphos_MorphOS'#010+
'S*2Tlinux_Linux'#010+
'S*2Tlinux_Linux'#010,
'**1u<x>_undefines the symbol <x>'#010+
'**1U_unit options:'#010+
'**2Un_don'#039't check the unit name'#010+
'**2Ur_generate release unit files'#010+
'**2Us_compile a system unit'#010+
'**1v<x>_Be verbose. <x> is a combination of t','he following letters:'#010+
'**2*_e : Show errors (default) d : Show debug info'#010+
'**1v<x>_Be verbose. <x> is a combination of the following letters:'#010+
'**2*_e : Show errors (defau','lt) d : Show debug info'#010+
'**2*_w : Show warnings u : Show unit info'#010+
'**2*_n : Show notes t : Show tried/used files'#010+
'**2*_h : Show hints m : S','how defined macros'#010+
'**2*_i : Show general info p : Show compiled procedures'#010+
'**2*_h : Show hints m : Show defined macros'#010+
'**2*_i : Show general info ',' p : Show compiled procedures'#010+
'**2*_l : Show linenumbers c : Show conditionals'#010+
'**2*_a : Show everything 0 : Show nothing (except errors)'#010+
'**2*_b : Show all procedur','e r : Rhide/GCC compatibility mod'+
'e'#010+
'**2*_ declarations if an error x : Executable info (Win32 only)'#010+
'**2*_b : Show all procedure r : Rhide/GCC compatibility mode'#010+
'**2*_',' declarations if an error x : Executable info (Win32 only'+
')'#010+
'**2*_ occurs'#010+
'**1V_write fpcdebug.txt file with lots of debugging info'#010+
'3*1W<x>_Win32-like target options'#010+
'3*2WB<x>_Set Image ','base to Hexadecimal <x> value'#010+
'3*2WC_Specify console type application'#010+
'3*2WB<x>_Set Image base to Hexadecimal <x> value'#010+
'3*2WC_Specify conso','le type application'#010+
'3*2WD_Use DEFFILE to export functions of DLL or EXE'#010+
'3*2WF_Specify full-screen type application (OS/2 only)'#010+
'3*2WG_Specify graphic type application'#010+
'3*2WN_Do not generate rel','ocation code (necessary for debugging)'#010+
'3*2WR_Generate relocation code'#010+
'3*2WN_Do not generate relocation code (necessary for debugging)'#010+
'3*2WR_Gene','rate relocation code'#010+
'P*2WC_Specify console type application (MacOS only)'#010+
'P*2WG_Specify graphic type application (MacOS only)'#010+
'P*2WT_Specify tool type application (MPW tool, MacOS only)'#010+
'**1X_ex','ecutable options:'#010+
'**1X_executable options:'#010+
'**2Xc_link with the c library'#010+
'**2Xd_don'#039't use standard library search path (needed for cross com'+
'pile)'#010+
'*','*2Xd_don'#039't use standard library search path (needed for cross c'+
'ompile)'#010+
'**2XD_try to link units dynamic (defines FPC_LINK_DYNAMIC)'#010+
'**2XP<x>_prepend the binutils names with the prefix ','<x>'#010+
'**2Xr<x>_set library search path to <x> (needed for cross compile)'#010+
'**2XP<x>_prepend the binutils names with the prefix <x>'#010+
'**2Xr<x>_set library search path to <x> (need','ed for cross compile)'#010+
'**2Xs_strip all symbols from executable'#010+
'**2XS_try to link units static (default) (defines FPC_LINK_STATIC)'#010+
'**2Xt_link with static libraries (-static is passed to linker)',#010+
'**2XX_try to link units smart (defines FPC_LINK_SMART)'#010+
'**2Xt_link with static libraries (-static is passed to linker)'#010+
'**2XX_try to link units smart (define','s FPC_LINK_SMART)'#010+
'**1*_'#010+
'**1?_shows this help'#010+
'**1h_shows this help without waiting'#000

View File

@ -395,17 +395,29 @@ implementation
set_varstate(left,vs_used,true);
if codegenerror then
exit;
if not is_boolean(left.resulttype.def) then
CGMessage1(type_e_boolean_expr_expected,left.resulttype.def.typename);
{ optimize constant expressions }
if (left.nodetype=ordconstn) and
(tordconstnode(left).value=0) then
if (left.nodetype=ordconstn) then
begin
if assigned(right) then
CGMessagePos(right.fileinfo,cg_w_unreachable_code);
result:=cnothingnode.create;
{ while false do }
if (lnf_testatbegin in loopflags) and
(tordconstnode(left).value=0) then
begin
if assigned(right) then
CGMessagePos(right.fileinfo,cg_w_unreachable_code);
result:=cnothingnode.create;
end
else
{ repeat until true }
if not(lnf_testatbegin in loopflags) and
(tordconstnode(left).value=1) then
begin
result:=right;
right:=nil;
end;
end;
end;
@ -568,7 +580,7 @@ implementation
if not is_boolean(left.resulttype.def) then
Message1(type_e_boolean_expr_expected,left.resulttype.def.typename);
{ optimize constant expressions }
if left.nodetype=ordconstn then
begin
@ -579,7 +591,7 @@ implementation
else
result:=cnothingnode.create;
right:=nil;
if assigned(t1) then
if assigned(t1) then
CGMessagePos(t1.fileinfo,cg_w_unreachable_code);
end
else
@ -589,7 +601,7 @@ implementation
else
result:=cnothingnode.create;
t1:=nil;
if assigned(right) then
if assigned(right) then
CGMessagePos(right.fileinfo,cg_w_unreachable_code);
end;
end;
@ -1429,7 +1441,10 @@ begin
end.
{
$Log$
Revision 1.105 2005-01-16 10:50:32 peter
Revision 1.106 2005-01-16 14:44:03 peter
* fix unreachable code check for repeat loop
Revision 1.105 2005/01/16 10:50:32 peter
* give warning for unreachable code in while/if statements
Revision 1.104 2005/01/03 17:55:57 florian