INTEGRATION: CWS warnings01 (1.8.12); FILE MERGED

2005/11/21 16:28:39 sb 1.8.12.5: #i53898# Made code warning-free.
2005/09/23 00:04:06 sb 1.8.12.4: RESYNC: (1.8-1.9); FILE MERGED
2005/09/13 13:28:59 sb 1.8.12.3: #i53898# Fixed handling of integral literals.
2005/09/05 12:26:05 sb 1.8.12.2: #i53898# Made code warning-free.
2005/08/29 14:14:23 sb 1.8.12.1: #i53898# Made code warning-free.
This commit is contained in:
Jens-Heiner Rechtien 2006-06-20 02:47:18 +00:00
parent 80399ca6b1
commit d03c46087f

View file

@ -4,9 +4,9 @@
*
* $RCSfile: astexpression.cxx,v $
*
* $Revision: 1.9 $
* $Revision: 1.10 $
*
* last change: $Author: rt $ $Date: 2005-09-07 18:07:18 $
* last change: $Author: hr $ $Date: 2006-06-20 03:47:18 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@ -249,31 +249,31 @@ coerce_value(AstExprValue *ev, ExprType t)
case ET_short:
return ev;
case ET_ushort:
if ((sal_uInt16)ev->u.usval > SHRT_MAX)
if (ev->u.usval > SAL_MAX_INT16)
return NULL;
ev->u.sval = (sal_Int16)ev->u.usval;
ev->et = ET_short;
return ev;
case ET_long:
if (ev->u.lval > SHRT_MAX || ev->u.lval < SHRT_MIN)
return NULL;
if (ev->u.lval < SAL_MIN_INT16 || ev->u.lval > SAL_MAX_INT16)
return NULL;
ev->u.sval = (sal_Int16)ev->u.lval;
ev->et = ET_short;
return ev;
case ET_ulong:
if (ev->u.ulval > SHRT_MAX)
if (ev->u.ulval > SAL_MAX_INT16)
return NULL;
ev->u.sval = (sal_Int16)ev->u.ulval;
ev->et = ET_short;
return ev;
case ET_hyper:
if (ev->u.hval > SHRT_MAX || ev->u.hval < SHRT_MIN)
if (ev->u.hval < SAL_MIN_INT16 || ev->u.hval > SAL_MAX_INT16)
return NULL;
ev->u.sval = (sal_Int16)ev->u.hval;
ev->et = ET_short;
return ev;
case ET_uhyper:
if (ev->u.uhval > SHRT_MAX)
if (ev->u.uhval > SAL_MAX_INT16)
return NULL;
ev->u.sval = (sal_Int16)ev->u.uhval;
ev->et = ET_short;
@ -283,13 +283,13 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->et = ET_short;
return ev;
case ET_float:
if (ev->u.fval > SHRT_MAX || ev->u.fval < SHRT_MIN)
if (ev->u.fval < SAL_MIN_INT16 || ev->u.fval > SAL_MAX_INT16)
return NULL;
ev->u.sval = (sal_Int16)ev->u.fval;
ev->et = ET_short;
return ev;
case ET_double:
if (ev->u.dval > SHRT_MAX || ev->u.dval < SHRT_MIN)
if (ev->u.dval < SAL_MIN_INT16 || ev->u.dval > SAL_MAX_INT16)
return NULL;
ev->u.sval = (sal_Int16)ev->u.dval;
ev->et = ET_short;
@ -314,25 +314,25 @@ coerce_value(AstExprValue *ev, ExprType t)
case ET_ushort:
return ev;
case ET_long:
if (ev->u.lval > USHRT_MAX || ev->u.lval < 0)
if (ev->u.lval < 0 || ev->u.lval > SAL_MAX_UINT16)
return NULL;
ev->u.usval = (sal_uInt16)ev->u.lval;
ev->et = ET_ushort;
return ev;
case ET_ulong:
if (ev->u.ulval > USHRT_MAX)
if (ev->u.ulval > SAL_MAX_UINT16)
return NULL;
ev->u.usval = (sal_uInt16)ev->u.ulval;
ev->et = ET_ushort;
return ev;
case ET_hyper:
if (ev->u.hval > USHRT_MAX || ev->u.hval < 0)
if (ev->u.hval < 0 || ev->u.hval > SAL_MAX_UINT16)
return NULL;
ev->u.usval = (sal_uInt16)ev->u.hval;
ev->et = ET_ushort;
return ev;
case ET_uhyper:
if (ev->u.uhval > USHRT_MAX)
if (ev->u.uhval > SAL_MAX_UINT16)
return NULL;
ev->u.usval = (sal_uInt16)ev->u.uhval;
ev->et = ET_ushort;
@ -342,13 +342,13 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->et = ET_short;
return ev;
case ET_float:
if (ev->u.fval < 0.0 || ev->u.fval > USHRT_MAX)
if (ev->u.fval < 0.0 || ev->u.fval > SAL_MAX_UINT16)
return NULL;
ev->u.usval = (sal_uInt16)ev->u.fval;
ev->et = ET_short;
return ev;
case ET_double:
if (ev->u.dval < 0.0 || ev->u.dval > USHRT_MAX)
if (ev->u.dval < 0.0 || ev->u.dval > SAL_MAX_UINT16)
return NULL;
ev->u.usval = (sal_uInt16)ev->u.dval;
ev->et = ET_short;
@ -375,19 +375,19 @@ coerce_value(AstExprValue *ev, ExprType t)
case ET_long:
return ev;
case ET_ulong:
if ((sal_Int32)ev->u.ulval > SAL_MAX_INT32)
if (ev->u.ulval > SAL_MAX_INT32)
return NULL;
ev->u.lval = (sal_Int32)ev->u.ulval;
ev->et = ET_long;
return ev;
case ET_hyper:
if ((sal_Int32)ev->u.hval > SAL_MAX_INT32 || (sal_Int32)ev->u.hval < SAL_MIN_INT32)
if (ev->u.hval < SAL_MIN_INT32 || ev->u.hval > SAL_MAX_INT32)
return NULL;
ev->u.lval = (sal_Int32)ev->u.hval;
ev->et = ET_long;
return ev;
case ET_uhyper:
if ((sal_Int32)ev->u.uhval > SAL_MAX_INT32)
if (ev->u.uhval > SAL_MAX_INT32)
return NULL;
ev->u.lval = (sal_Int32)ev->u.uhval;
ev->et = ET_long;
@ -397,13 +397,13 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->et = ET_long;
return ev;
case ET_float:
if ((sal_Int32)ev->u.fval > SAL_MAX_INT32 || (sal_Int32)ev->u.fval < SAL_MIN_INT32)
if (ev->u.fval < SAL_MIN_INT32 || ev->u.fval > SAL_MAX_INT32)
return NULL;
ev->u.lval = (sal_Int32)ev->u.fval;
ev->et = ET_long;
return ev;
case ET_double:
if ((sal_Int32)ev->u.dval > SAL_MAX_INT32 || (sal_Int32)ev->u.dval < SAL_MIN_INT32)
if (ev->u.dval < SAL_MIN_INT32 || ev->u.dval > SAL_MAX_INT32)
return NULL;
ev->u.lval = (sal_Int32)ev->u.dval;
ev->et = ET_long;
@ -430,7 +430,7 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->et = ET_ulong;
return ev;
case ET_long:
if ((sal_uInt32)ev->u.lval < 0 && (sal_uInt32)ev->u.lval != SAL_MAX_UINT32)
if (ev->u.lval < 0)
return NULL;
ev->u.ulval = (sal_uInt32)ev->u.lval;
ev->et = ET_ulong;
@ -438,13 +438,13 @@ coerce_value(AstExprValue *ev, ExprType t)
case ET_ulong:
return ev;
case ET_hyper:
if (ev->u.hval > (sal_Int64)SAL_MAX_UINT32 || ev->u.hval < 0)
if (ev->u.hval < 0 || ev->u.hval > SAL_MAX_UINT32)
return NULL;
ev->u.lval = (sal_uInt32)ev->u.hval;
ev->et = ET_ulong;
return ev;
case ET_uhyper:
if (ev->u.uhval > (sal_uInt64)SAL_MAX_UINT32)
if (ev->u.uhval > SAL_MAX_UINT32)
return NULL;
ev->u.ulval = (sal_uInt32)ev->u.uhval;
ev->et = ET_ulong;
@ -454,13 +454,13 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->et = ET_ulong;
return ev;
case ET_float:
if (ev->u.fval < 0.0 || (sal_uInt32)ev->u.fval > SAL_MAX_UINT32)
if (ev->u.fval < 0.0 || ev->u.fval > SAL_MAX_UINT32)
return NULL;
ev->u.ulval = (sal_uInt32)ev->u.fval;
ev->et = ET_ulong;
return ev;
case ET_double:
if (ev->u.dval < 0.0 || (sal_uInt32)ev->u.dval > SAL_MAX_UINT32)
if (ev->u.dval < 0.0 || ev->u.dval > SAL_MAX_UINT32)
return NULL;
ev->u.ulval = (sal_uInt32)ev->u.dval;
ev->et = ET_ulong;
@ -495,7 +495,7 @@ coerce_value(AstExprValue *ev, ExprType t)
case ET_hyper:
return ev;
case ET_uhyper:
if (ev->u.uhval > (sal_uInt64)SAL_MAX_INT64)
if (ev->u.uhval > SAL_MAX_INT64)
return NULL;
ev->u.hval = (sal_Int64)ev->u.uhval;
ev->et = ET_long;
@ -505,13 +505,13 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->et = ET_hyper;
return ev;
case ET_float:
if ((sal_Int64)ev->u.fval > SAL_MAX_INT64 || (sal_Int64)ev->u.fval < SAL_MIN_INT64)
if (ev->u.fval < SAL_MIN_INT64 || ev->u.fval > SAL_MAX_INT64)
return NULL;
ev->u.hval = (sal_Int64)ev->u.fval;
ev->et = ET_hyper;
return ev;
case ET_double:
if ((sal_Int64)ev->u.dval > SAL_MAX_INT64 || (sal_Int64)ev->u.dval < SAL_MIN_INT64)
if (ev->u.dval < SAL_MIN_INT64 || ev->u.dval > SAL_MAX_INT64)
return NULL;
ev->u.hval = (sal_Int64)ev->u.dval;
ev->et = ET_hyper;
@ -538,7 +538,7 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->et = ET_uhyper;
return ev;
case ET_long:
if ((sal_uInt64)ev->u.lval < 0 && ev->u.lval != SAL_MAX_UINT64)
if (ev->u.lval < 0)
return NULL;
ev->u.uhval = (sal_uInt64)ev->u.lval;
ev->et = ET_uhyper;
@ -548,7 +548,7 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->et = ET_uhyper;
return ev;
case ET_hyper:
if ((sal_uInt64)ev->u.hval < 0 && ev->u.hval != SAL_MAX_UINT64)
if (ev->u.hval < 0)
return NULL;
ev->u.uhval = (sal_uInt64)ev->u.hval;
ev->et = ET_uhyper;
@ -560,13 +560,13 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->et = ET_uhyper;
return ev;
case ET_float:
if (ev->u.fval < 0.0 || (sal_uInt64)ev->u.fval > SAL_MAX_UINT64)
if (ev->u.fval < 0.0 || ev->u.fval > SAL_MAX_UINT64)
return NULL;
ev->u.uhval = (sal_uInt64)ev->u.fval;
ev->et = ET_uhyper;
return ev;
case ET_double:
if (ev->u.dval < 0.0 || (sal_uInt64)ev->u.dval > SAL_MAX_UINT64)
if (ev->u.dval < 0.0 || ev->u.dval > SAL_MAX_UINT64)
return NULL;
ev->u.uhval = (sal_uInt64)ev->u.dval;
ev->et = ET_uhyper;
@ -653,7 +653,6 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->u.fval = (float)ev->u.ulval;
ev->et = ET_float;
return ev;
return NULL;
case ET_boolean:
ev->u.fval = (ev->u.bval == sal_True) ? 1.0f : 0.0f;
ev->et = ET_float;
@ -725,37 +724,37 @@ coerce_value(AstExprValue *ev, ExprType t)
switch (ev->et)
{
case ET_short:
if (ev->u.sval < 0 || (sal_uChar)ev->u.sval > (MAXCHAR << 1))
if (ev->u.sval < SAL_MIN_INT8 || ev->u.sval > SAL_MAX_UINT8)
return NULL;
ev->u.byval = (sal_uChar)ev->u.sval;
ev->et = ET_byte;
return ev;
case ET_ushort:
if ((sal_uChar)ev->u.usval > (MAXCHAR << 1))
if (ev->u.usval > SAL_MAX_UINT8)
return NULL;
ev->u.byval = (sal_uChar)ev->u.usval;
ev->et = ET_byte;
return ev;
case ET_long:
if (ev->u.lval < 0 || (sal_uChar)ev->u.lval > (MAXCHAR << 1))
if (ev->u.lval < SAL_MIN_INT8 || ev->u.lval > SAL_MAX_UINT8)
return NULL;
ev->u.byval = (sal_uChar) ev->u.lval;
ev->et = ET_byte;
return ev;
case ET_ulong:
if ((sal_uChar)ev->u.ulval > (MAXCHAR << 1))
if (ev->u.ulval > SAL_MAX_UINT8)
return NULL;
ev->u.byval = (sal_uChar) ev->u.ulval;
ev->et = ET_byte;
return ev;
case ET_hyper:
if (ev->u.hval < 0 || (sal_uChar)ev->u.hval > (MAXCHAR << 1))
if (ev->u.hval < SAL_MIN_INT8 || ev->u.hval > SAL_MAX_UINT8)
return NULL;
ev->u.byval = (sal_uChar) ev->u.hval;
ev->et = ET_byte;
return ev;
case ET_uhyper:
if ((sal_uChar)ev->u.uhval > (MAXCHAR << 1))
if (ev->u.uhval > SAL_MAX_UINT8)
return NULL;
ev->u.byval = (sal_uChar) ev->u.uhval;
ev->et = ET_byte;
@ -765,13 +764,13 @@ coerce_value(AstExprValue *ev, ExprType t)
ev->et = ET_byte;
return ev;
case ET_float:
if (ev->u.fval < 0.0 || (sal_uChar)ev->u.fval > (MAXCHAR << 1))
if (ev->u.fval < SAL_MIN_INT8 || ev->u.fval > SAL_MAX_UINT8)
return NULL;
ev->u.byval = (sal_uChar) ev->u.fval;
ev->et = ET_byte;
return ev;
case ET_double:
if (ev->u.dval < 0.0 || (sal_uChar)ev->u.dval > (MAXCHAR << 1))
if (ev->u.dval < SAL_MIN_INT8 || ev->u.dval > SAL_MAX_UINT8)
return NULL;
ev->u.byval = (sal_uChar) ev->u.dval;
ev->et = ET_byte;
@ -1223,7 +1222,7 @@ AstExprValue* AstExpression::eval_symbol(EvalKind ek)
/*
* OK, now evaluate the constant we just got, to produce its value
*/
pConst = reinterpret_cast< AstConstant* >(pDecl);
pConst = static_cast< AstConstant* >(pDecl);
if (pConst == NULL)
return NULL;
return pConst->getConstValue()->eval_internal(ek);
@ -1278,6 +1277,9 @@ OString AstExpression::toString()
break;
case EC_bit_neg:
exprStr += OString("~");
break;
default:
break;
}
if ( m_subExpr1 )
exprStr += m_subExpr1->toString();
@ -1313,6 +1315,8 @@ OString AstExpression::toString()
case EC_right:
exprStr += OString(" >> ");
break;
default:
break;
}
if ( m_subExpr2 )