20000507-13:35 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* include/hberrors.h
+ Added : #define HB_COMP_WARN_VAL_NOT_USED 20
* source/compiler/harbour.c
+ Added logic to hb_compOptimizeFrames() to warn about invalid statics usage.
* source/compiler/hbgenerr.c
+ Added: "3Value of Variable \'%s\' never used"
* source/compiler/hbpcode.c
* Enhanced support for statics
* tests/testwarn.prg
+ Added more code to demonstrate more warnings.
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
20000507-13:35 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
|
||||
|
||||
* include/hberrors.h
|
||||
+ Added : #define HB_COMP_WARN_VAL_NOT_USED 20
|
||||
|
||||
* source/compiler/harbour.c
|
||||
+ Added logic to hb_compOptimizeFrames() to warn about invalid statics usage.
|
||||
|
||||
* source/compiler/hbgenerr.c
|
||||
+ Added: "3Value of Variable \'%s\' never used"
|
||||
|
||||
* source/compiler/hbpcode.c
|
||||
* Enhanced support for statics
|
||||
|
||||
* tests/testwarn.prg
|
||||
+ Added more code to demonstrate more warnings.
|
||||
|
||||
20000507-05:20 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
|
||||
|
||||
* include/hbpcomp.c
|
||||
@@ -10,11 +27,12 @@
|
||||
+ Added support for MEMVAR AS ... syntax.
|
||||
|
||||
* source/compiler/hbpcode.c
|
||||
+ Added static PVAR hb_compPrivateFind( char * szPrivateName )
|
||||
+ Added support for FIELD AS ... and MEMVAR AS both local and global.
|
||||
! More refinments
|
||||
|
||||
* tests/testwarn.prg
|
||||
+ Added code to demonstrate "Adaptive Type Checking".
|
||||
+ Added more code to demonstrate more warnings.
|
||||
|
||||
20000507-14:05 GMT+1 Ryszard Glab <rglab@imid.med.pl>
|
||||
|
||||
|
||||
@@ -110,11 +110,12 @@ extern "C" {
|
||||
#define HB_COMP_WARN_DUP_DECLARATION 17
|
||||
#define HB_COMP_WARN_DECLARATION_CONFLICT 18
|
||||
#define HB_COMP_WARN_NOT_INITIALIZED 19
|
||||
#define HB_COMP_WARN_ARRAY_ASSIGN_TYPE 20
|
||||
#define HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT 21
|
||||
#define HB_COMP_WARN_MEANINGLESS 22
|
||||
#define HB_COMP_WARN_UNREACHABLE 23
|
||||
#define HB_COMP_WARN_DUPL_ANNOUNCE 24
|
||||
#define HB_COMP_WARN_VAL_NOT_USED 20
|
||||
#define HB_COMP_WARN_ARRAY_ASSIGN_TYPE 21
|
||||
#define HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT 22
|
||||
#define HB_COMP_WARN_MEANINGLESS 23
|
||||
#define HB_COMP_WARN_UNREACHABLE 24
|
||||
#define HB_COMP_WARN_DUPL_ANNOUNCE 25
|
||||
|
||||
/*
|
||||
* Errors generated by Harbour preprocessor
|
||||
|
||||
@@ -258,9 +258,6 @@ int main( int argc, char * argv[] )
|
||||
if( ! hb_comp_bStartProc )
|
||||
--hb_comp_iFunctionCnt;
|
||||
|
||||
if( ! hb_comp_bQuiet )
|
||||
printf( "\rLines %i, Functions/Procedures %i\n", hb_comp_iLine, hb_comp_iFunctionCnt );
|
||||
|
||||
pFunc = hb_comp_functions.pFirst;
|
||||
while( pFunc )
|
||||
{
|
||||
@@ -268,6 +265,9 @@ int main( int argc, char * argv[] )
|
||||
pFunc = pFunc->pNext;
|
||||
}
|
||||
|
||||
if( ! hb_comp_bQuiet )
|
||||
printf( "\rLines %i, Functions/Procedures %i\n", hb_comp_iLine, hb_comp_iFunctionCnt );
|
||||
|
||||
hb_compGenOutput( hb_comp_iLanguage );
|
||||
}
|
||||
}
|
||||
@@ -2654,6 +2654,24 @@ static void hb_compOptimizeFrames( PFUNCTION pFunc )
|
||||
pFunc->lPCodePos -= 3;
|
||||
memmove( pFunc->pCode + 5, pFunc->pCode + 8, pFunc->lPCodePos - 5 );
|
||||
}
|
||||
else
|
||||
/* Check Global Statics. */
|
||||
{
|
||||
//PVAR pVar = pFunc->pStatics;
|
||||
PVAR pVar = hb_comp_functions.pFirst->pStatics;
|
||||
|
||||
while( pVar )
|
||||
{
|
||||
//printf( "\nChecking: %s Used: %i\n", pVar->szName, pVar->iUsed );
|
||||
|
||||
if ( ( ! pVar->iUsed & VU_USED ) && pVar->iUsed & VU_INITIALIZED )
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_VAL_NOT_USED, pVar->szName, NULL );
|
||||
else if ( pVar->iUsed & VU_USED && ! ( pVar->iUsed & VU_INITIALIZED ) )
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL );
|
||||
|
||||
pVar = pVar->pNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( pFunc->pCode[ 0 ] == HB_P_FRAME &&
|
||||
|
||||
@@ -110,6 +110,7 @@ char * hb_comp_szWarnings[] =
|
||||
"3Duplicate Declaration of Function %s",
|
||||
"3Function \'%s\' conflicting with its declaration",
|
||||
"3Variable \'%s\' used but never initialized",
|
||||
"3Value of Variable \'%s\' never used",
|
||||
"3Incompatible type in assignment to declared array element expected: \'%s\'",
|
||||
"4Suspicious type in assignment to declared array element expected: \'%s\'",
|
||||
"0Meaningless use of expression: \'%s\'",
|
||||
|
||||
@@ -969,8 +969,12 @@ void hb_compStrongType( int iSize )
|
||||
|
||||
if ( pVar )
|
||||
{
|
||||
if ( ! ( pVar->iUsed & VU_INITIALIZED ) )
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL );
|
||||
//printf( "\nStatic: %s Function: %s Found in: %s\n", pVar->szName, pFunc->szName, pTmp->szName );
|
||||
|
||||
/* Only if "private" static, since global static may be intialized elsewhere. */
|
||||
if ( pTmp == pFunc )
|
||||
if ( ! ( pVar->iUsed & VU_INITIALIZED ) )
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL );
|
||||
|
||||
/* Mark as used */
|
||||
pVar->iUsed |= VU_USED;
|
||||
|
||||
@@ -66,8 +66,12 @@ FIELD b AS CHAR
|
||||
|
||||
MEMVAR Var1 AS CHAR
|
||||
|
||||
STATIC lGlobal AS LOGICAL
|
||||
|
||||
PROCEDURE THEMAIN()
|
||||
|
||||
STATIC lStatic := 0
|
||||
|
||||
FIELD b AS NUM
|
||||
USE TEMP
|
||||
|
||||
@@ -82,7 +86,13 @@ PROCEDURE THEMAIN()
|
||||
|
||||
b := 'a'
|
||||
|
||||
Var1 := .f.
|
||||
if lStatic
|
||||
Var1 := .F.
|
||||
endif
|
||||
|
||||
IF lGlobal
|
||||
Var1 := .T.
|
||||
ENDIF
|
||||
|
||||
RETURN
|
||||
|
||||
@@ -104,6 +114,9 @@ PROCEDURE SOMEPROC()
|
||||
|
||||
Var1 := 1
|
||||
|
||||
if lGlobal = 0
|
||||
endif
|
||||
|
||||
RETURN
|
||||
PROC MAIN1()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user