diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f03df3768a..c3bccd99d6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-12-24 03:23 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) + * include/hberrors.h + * source/compiler/hbgenerr.c + * source/compiler/hbopt.c + + implemented warning: Variable '%s' is never assigned in function %s(%d). + This variable can be replaced by value NIL + + * source/rtl/treport.prg + % removed never assigned variable + 2008-12-24 00:04 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/common/expropt1.c * harbour/source/common/expropt2.c diff --git a/harbour/include/hberrors.h b/harbour/include/hberrors.h index 48ceaf54c4..94b68e979e 100644 --- a/harbour/include/hberrors.h +++ b/harbour/include/hberrors.h @@ -165,6 +165,7 @@ HB_EXTERN_BEGIN #define HB_COMP_WARN_FORVAR_DUPL 30 #define HB_COMP_WARN_ENUM_INVALID 31 #define HB_COMP_WARN_ASSIGNED_UNUSED 32 +#define HB_COMP_WARN_NEVER_ASSIGNED 33 HB_EXTERN_END diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index d99422309c..e7c1d92556 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -144,7 +144,8 @@ const char * hb_comp_szWarnings[] = "1Redundant 'ANNOUNCE %s' statement ignored", "0Duplicate variable '%s' in nested FOR loop", "0Invalid variable '%s' for enumerator message", - "3Variable '%s' assigned but not used in function '%s'" + "3Variable '%s' is assigned but not used in function '%s'", + "3Variable '%s' is never assigned in function '%s'" }; static void hb_compDispMessage( HB_COMP_DECL, char cPrefix, int iValue, diff --git a/harbour/source/compiler/hbopt.c b/harbour/source/compiler/hbopt.c index 2ac3c534d0..3754c85edf 100644 --- a/harbour/source/compiler/hbopt.c +++ b/harbour/source/compiler/hbopt.c @@ -1467,12 +1467,18 @@ void hb_compPCodeTraceOptimizer( HB_COMP_DECL ) pVar = pFunc->pLocals; while( pVar ) { - /* TOFIX: PARAMETERS sentence - The temporary solution is to disable optmisation if PARAMETERS is used. - */ /* Compiler and optimizer should have the same opinion about variable usage */ assert( ( ! ( pVar->iUsed & VU_USED ) && pLocals[ usIndex ].bFlags == 0 ) || ( ( pVar->iUsed & VU_USED ) && pLocals[ usIndex ].bFlags != 0 ) ); + + if( usIndex >= pFunc->wParamCount && pLocals[ usIndex ].bFlags == OPT_LOCAL_FLAG_PUSH ) + { + char szFun[ 256 ]; + + hb_snprintf( szFun, sizeof( szFun ), "%s(%i)", pFunc->szName, pVar->iDeclLine ); + hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_NEVER_ASSIGNED, pVar->szName, szFun ); + } + pVar = pVar->pNext; usIndex++; } diff --git a/harbour/source/rtl/treport.prg b/harbour/source/rtl/treport.prg index f638915d9f..065dc60ddb 100644 --- a/harbour/source/rtl/treport.prg +++ b/harbour/source/rtl/treport.prg @@ -463,7 +463,6 @@ METHOD ReportHeader() CLASS HBReportForm LOCAL nHeadline LOCAL nRPageSize LOCAL aTempPgHeader - LOCAL nHeadSize nRPageSize := ::aReportData[RPT_WIDTH] - ::aReportData[RPT_RMARGIN] @@ -495,12 +494,12 @@ METHOD ReportHeader() CLASS HBReportForm ENDIF FOR nLine := 1 TO Len( ::aReportData[ RPT_HEADER]) nLinesInHeader := Max( XMLCOUNT(LTrim( ::aReportData[RPT_HEADER,; - nLine ] ), nHeadSize),1 ) + nLine ] )),1 ) FOR nHeadLine := 1 to nLinesInHeader - cHeader := RTrim( XMEMOLINE( LTrim( ::aReportData[RPT_HEADER, nLine ]),; - nHeadSize,nHeadLine)) + cHeader := RTrim( XMEMOLINE( LTrim( ::aReportData[RPT_HEADER, nLine ]),,; + nHeadLine)) AAdd( aPageHeader, Space((nRPageSize - ::aReportData[ RPT_LMARGIN ] -; Len( cHeader ) ) / 2 ) + cHeader )