2023-11-13 23:58 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* contrib/hbct/ctwin.c
    ! typo in comment

  * include/hbexprb.c
  * include/hbexprop.h
  * src/common/expropt2.c
  * src/harbour.def
    * moved code for reducing NOT expression to new separate function
      hb_compExprReduceNot()
    ; added comments to mark places for possible compiletime warnings when
      incompatible types are used inside in logical expressions
      (.AND. / .OR. / .NOT.)
This commit is contained in:
Przemysław Czerpak
2023-11-13 23:58:30 +01:00
parent ffadb8459d
commit 6bbb31e540
6 changed files with 65 additions and 23 deletions

View File

@@ -7,6 +7,20 @@
Entries may not always be in chronological/commit order.
See license at the end of file. */
2023-11-13 23:58 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbct/ctwin.c
! typo in comment
* include/hbexprb.c
* include/hbexprop.h
* src/common/expropt2.c
* src/harbour.def
* moved code for reducing NOT expression to new separate function
hb_compExprReduceNot()
; added comments to mark places for possible compiletime warnings when
incompatible types are used inside in logical expressions
(.AND. / .OR. / .NOT.)
2023-11-12 16:40 UTC+0100 Phil Krylov (phil a t krylov.eu)
* .github/workflows/linux-ci.yml
* .github/workflows/macos-ci.yml

View File

@@ -1947,7 +1947,7 @@ static HB_BOOL hb_ctw_gt_PutChar( PHB_GT pGT, int iRow, int iCol,
iWindow = pCTW->pWindowMap[ lIndex ];
#if 0
/* When window with shadow is closed CT3 restores attributes
* which existed before shadow was displayed. In some application
* which existed before shadow was displayed. In an application
* which switches to window 0 for pass-throw output it causes that
* wrong attributes appears after this operation. In Harbour it's
* fixed so such problem do not exist. Anyhow some code may switch

View File

@@ -3407,30 +3407,10 @@ static HB_EXPR_FUNC( hb_compExprUseNot )
switch( iMessage )
{
case HB_EA_REDUCE:
{
PHB_EXPR pExpr;
pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE );
pExpr = pSelf->value.asOperator.pLeft;
if( pExpr->ExprType == HB_ET_LOGICAL )
{
pExpr->value.asLogical = ! pExpr->value.asLogical;
HB_COMP_EXPR_CLEAR( pSelf );
pSelf = pExpr;
}
else if( pExpr->ExprType == HB_EO_NOT && HB_SUPPORT_EXTOPT )
{
/* NOTE: This will not generate a runtime error if incompatible
* data type is used
*/
pExpr->ExprType = HB_ET_NONE; /* do not delete operator parameter - we are still using it */
pExpr = pExpr->value.asOperator.pLeft;
HB_COMP_EXPR_FREE( pSelf );
pSelf = pExpr;
}
pSelf = hb_compExprReduceNot( pSelf, HB_COMP_PARAM );
break;
}
case HB_EA_ARRAY_AT:
HB_COMP_ERROR_TYPE( pSelf );
break;

View File

@@ -179,6 +179,7 @@ extern HB_EXPORT_INT PHB_EXPR hb_compExprReduceLT( PHB_EXPR pSelf, HB_COMP_DECL
extern HB_EXPORT_INT PHB_EXPR hb_compExprReduceEQ( PHB_EXPR pSelf, HB_COMP_DECL );
extern HB_EXPORT_INT PHB_EXPR hb_compExprReduceAnd( PHB_EXPR pSelf, HB_COMP_DECL );
extern HB_EXPORT_INT PHB_EXPR hb_compExprReduceOr( PHB_EXPR pSelf, HB_COMP_DECL );
extern HB_EXPORT_INT PHB_EXPR hb_compExprReduceNot( PHB_EXPR pSelf, HB_COMP_DECL );
extern HB_EXPORT_INT PHB_EXPR hb_compExprReduceIIF( PHB_EXPR, HB_COMP_DECL );
extern HB_EXPORT_INT HB_BOOL hb_compExprReduceAT( PHB_EXPR, HB_COMP_DECL );

View File

@@ -967,6 +967,11 @@ PHB_EXPR hb_compExprReduceNegate( PHB_EXPR pSelf, HB_COMP_DECL )
HB_COMP_EXPR_FREE( pSelf );
pSelf = pExpr;
}
/* TODO: add checking of incompatible types
else
{
}
*/
return pSelf;
}
@@ -1798,6 +1803,11 @@ PHB_EXPR hb_compExprReduceAnd( PHB_EXPR pSelf, HB_COMP_DECL )
pSelf->value.asLogical = HB_FALSE;
}
}
/* TODO: add checking of incompatible types
else
{
}
*/
return pSelf;
}
@@ -1866,6 +1876,42 @@ PHB_EXPR hb_compExprReduceOr( PHB_EXPR pSelf, HB_COMP_DECL )
pSelf = pLeft;
}
}
/* TODO: add checking of incompatible types
else
{
}
*/
return pSelf;
}
PHB_EXPR hb_compExprReduceNot( PHB_EXPR pSelf, HB_COMP_DECL )
{
PHB_EXPR pExpr;
pExpr = pSelf->value.asOperator.pLeft;
if( pExpr->ExprType == HB_ET_LOGICAL )
{
pExpr->value.asLogical = ! pExpr->value.asLogical;
HB_COMP_EXPR_CLEAR( pSelf ); /* suppress deletion of operator components */
pSelf = pExpr;
}
else if( pExpr->ExprType == HB_EO_NOT && HB_SUPPORT_EXTOPT )
{
/* NOTE: This will not generate a runtime error if incompatible
* data type is used
*/
pExpr->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
pExpr = pExpr->value.asOperator.pLeft;
HB_COMP_EXPR_FREE( pSelf );
pSelf = pExpr;
}
/* TODO: add checking of incompatible types
else
{
}
*/
return pSelf;
}

View File

@@ -2327,6 +2327,7 @@ hb_compExprReduceMod
hb_compExprReduceMult
hb_compExprReduceNE
hb_compExprReduceNegate
hb_compExprReduceNot
hb_compExprReduceOr
hb_compExprReducePlus
hb_compExprReducePower