20000503-01:45 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* include/hberrors.h
+ Added:
#define HB_COMP_NOT_INITIALIZED
* source/compiler/hbgenerr.c
+ Added: "3Variable \'%s\' used but never initialized"
* source/compiler/hbpcode.c
* Enhanced hb_compStrongType() to warn against un-initialized varaiable usage.
This commit is contained in:
@@ -1,6 +1,18 @@
|
||||
20000503-01:45 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
|
||||
|
||||
* include/hberrors.h
|
||||
+ Added:
|
||||
#define HB_COMP_NOT_INITIALIZED
|
||||
|
||||
* source/compiler/hbgenerr.c
|
||||
+ Added: "3Variable \'%s\' used but never initialized"
|
||||
|
||||
* source/compiler/hbpcode.c
|
||||
* Enhanced hb_compStrongType() to warn against un-initialized varaiable usage.
|
||||
|
||||
20000503-01:00 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
|
||||
* source/compiler/hbpcode.c
|
||||
* Fixed hb_compStrongType() to difrentiate between a MEMVAR and a DECLARED FUNCTION with the same name.
|
||||
* Fixed hb_compStrongType() to diffrentiate between a MEMVAR and a DECLARED FUNCTION with the same name.
|
||||
+ Added support for HB_P_ARRAYPUSH
|
||||
|
||||
* source/compiler/hbgenerr.c
|
||||
@@ -40,8 +52,8 @@
|
||||
"3Function \'%s\' conflicting with its declaration"
|
||||
|
||||
* source/compiler/hbpcode.c
|
||||
* Modifief hb_compStrongType() to utilize PCOMDECLARED rather than PCOMSYMBOL
|
||||
* Modifief hb_compStrongType() to increase the pFunc->pStack as needed.
|
||||
* Modified hb_compStrongType() to utilize PCOMDECLARED rather than PCOMSYMBOL
|
||||
* Modified hb_compStrongType() to increase the pFunc->pStack as needed.
|
||||
|
||||
* tests/testwarn.prg
|
||||
+ Added code to demonstrate more warnings.
|
||||
|
||||
@@ -109,9 +109,10 @@ extern "C" {
|
||||
#define HB_COMP_PARAM_TYPE 16
|
||||
#define HB_COMP_DUP_DECLARATION 17
|
||||
#define HB_COMP_DECLARATION_CONFLICT 18
|
||||
#define HB_COMP_WARN_MEANINGLESS 19
|
||||
#define HB_COMP_WARN_UNREACHABLE 20
|
||||
#define HB_COMP_WARN_DUPL_ANNOUNCE 21
|
||||
#define HB_COMP_WARN_NOT_INITIALIZED 19
|
||||
#define HB_COMP_WARN_MEANINGLESS 20
|
||||
#define HB_COMP_WARN_UNREACHABLE 21
|
||||
#define HB_COMP_WARN_DUPL_ANNOUNCE 22
|
||||
|
||||
/*
|
||||
* Errors generated by Harbour preprocessor
|
||||
|
||||
@@ -109,6 +109,7 @@ char * hb_comp_szWarnings[] =
|
||||
"3Incompatible parameter number %s expected: \'%s\'",
|
||||
"3Duplicate Declaration of Function %s",
|
||||
"3Function \'%s\' conflicting with its declaration",
|
||||
"3Variable \'%s\' used but never initialized",
|
||||
"0Meaningless use of expression: \'%s\'",
|
||||
"2Unreachable code",
|
||||
"1Redundant \'ANNOUNCE %s\' statement ignored"
|
||||
|
||||
@@ -653,6 +653,9 @@ void hb_compStrongType( int iSize )
|
||||
|
||||
if ( pVar )
|
||||
{
|
||||
if ( pVar->iUsed >= 0 )
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL );
|
||||
|
||||
/* Review with Ryszard. */
|
||||
if ( pVar->cType == 'U' )
|
||||
pVar->cType = ' ';
|
||||
@@ -689,9 +692,8 @@ void hb_compStrongType( int iSize )
|
||||
|
||||
if ( pVar )
|
||||
{
|
||||
/* Review with Ryszard. */
|
||||
if ( pVar->cType == 'U' )
|
||||
pVar->cType = ' ';
|
||||
if ( pVar->iUsed >= 0 )
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL );
|
||||
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType;
|
||||
}
|
||||
@@ -713,14 +715,13 @@ void hb_compStrongType( int iSize )
|
||||
|
||||
if ( pVar )
|
||||
{
|
||||
/* Review with Ryszard. */
|
||||
if ( pVar->cType == 'U' )
|
||||
pVar->cType = ' ';
|
||||
if ( pVar->iUsed >= 0 )
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL );
|
||||
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType;
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType;
|
||||
}
|
||||
else
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = ' ';
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = ' ';
|
||||
|
||||
break;
|
||||
|
||||
@@ -917,6 +918,9 @@ void hb_compStrongType( int iSize )
|
||||
else
|
||||
pVar = hb_compVariableFind( pFunc->pLocals, wVar );
|
||||
|
||||
if ( pVar )
|
||||
pVar->iUsed = -1;
|
||||
|
||||
if ( pVar && pVar->cType != ' ' )
|
||||
{
|
||||
char szType[2];
|
||||
@@ -954,6 +958,9 @@ void hb_compStrongType( int iSize )
|
||||
else
|
||||
pVar = hb_compVariableFind( pFunc->pLocals, iVar );
|
||||
|
||||
if ( pVar )
|
||||
pVar->iUsed = -1;
|
||||
|
||||
if ( pVar && pVar->cType != ' ' )
|
||||
{
|
||||
char szType[2];
|
||||
@@ -982,6 +989,9 @@ void hb_compStrongType( int iSize )
|
||||
|
||||
pVar = hb_compVariableFind( pTmp->pStatics, wVar - pTmp->iStaticsBase );
|
||||
|
||||
if ( pVar )
|
||||
pVar->iUsed = -1;
|
||||
|
||||
if ( pVar && pVar->cType != ' ' )
|
||||
{
|
||||
char szType[2];
|
||||
|
||||
@@ -19,7 +19,14 @@ DECLARE FUNCTION int( n AS NUMERIC ) AS NUMERIC
|
||||
|
||||
DECLARE FUNCTION TEST AS NUMERIC
|
||||
|
||||
PROC MAIN0()
|
||||
PROCEDURE MAIN
|
||||
LOCAL RPT, APARAMS
|
||||
|
||||
Rpt := Array( Len( AParams ) - 2 )
|
||||
|
||||
RETURN
|
||||
|
||||
PROC MAIN1()
|
||||
PRIVATE OTHER, TEST AS CHAR
|
||||
|
||||
Var1 := M->TEST
|
||||
@@ -34,7 +41,7 @@ RETURN
|
||||
Function Test()
|
||||
return .t.
|
||||
|
||||
Function Main()
|
||||
Function Main2()
|
||||
Local n As Numeric, lVar AS LOGICAL
|
||||
|
||||
n := IIF( lVar, 'A', 3 )
|
||||
@@ -45,7 +52,7 @@ Function Main()
|
||||
|
||||
Return( NIL )
|
||||
|
||||
FUNCTION Main1()
|
||||
FUNCTION Main3()
|
||||
|
||||
LOCAL n AS NUMERIC, cVar AS CHARACTER, a[5,5,5] AS ARRAY
|
||||
|
||||
|
||||
Reference in New Issue
Block a user