-
- /* end modifications */
-
- sRef_setNullError (ret->sref);
-
- /*
- ** Fixed for 2.2c: the alias state of ptr + int is dependent,
- ** since is points to storage that should not be deallocated
- ** through this pointer.
- */
-
- if (sRef_isOnly (ret->sref)
- || sRef_isFresh (ret->sref))
- {
- sRef_setAliasKind (ret->sref, AK_DEPENDENT, exprNode_loc (ret));
- }
-
- tret = e1->typ;
- }
- else if ((!ctype_isRealPointer(tr1) && ctype_isRealInt (tr1))
- && (ctype_isRealPointer (tr2) && !exprNode_isNullValue (e2)))
- {
- if (context_msgPointerArith ())
- {
- voptgenerror
- (FLG_POINTERARITH,
- message ("Pointer arithmetic (%t, %t): %s",
- te1, te2, exprNode_unparse (ret)),
- e1->loc);
- }
-
- if (sRef_possiblyNull (e1->sref)
- && !usymtab_isGuarded (e1->sref))
- {
- voptgenerror
- (FLG_NULLPOINTERARITH,
- message ("Pointer arithmetic involving possibly "
- "null pointer %s: %s",
- exprNode_unparse (e2),
- exprNode_unparse (ret)),
- e2->loc);
- }
-
- ret->sref = sRef_copy (e2->sref);
-
- /* start modifications */
- /* added by Seejo on 4/16/2000 */
-
- /* Arithmetic operations on pointers wil modify the size/len/null terminated
- status */
-
- if ((sRef_isPossiblyNullTerminated (e2->sref)) || (sRef_isNullTerminated(e2->sref))) {
- //if (sRef_isKnown (e->sref)) {
- //ret->sref = sRef_makeAddress (e->sref);
- //}
-
- int val = (int) multiVal_forceInt (e1->val);
-
- /* Operator : + or += */
- if ((lltok_getTok (op) == TPLUS) || (lltok_getTok(op) == ADD_ASSIGN)) {
- if (sRef_getSize(e2->sref) >= val) {/* Incrementing the pointer by
- val should not result in a
- size < 0 (size = 0 is ok !) */
-
- sRef_setSize (ret->sref, sRef_getSize(e2->sref) - val);
-
- if (sRef_getLen(e2->sref) == val) { /* i.e. the character at posn val is \0 */
- sRef_setNotNullTerminatedState(ret->sref);
- sRef_resetLen (ret->sref);
- } else {
- sRef_setNullTerminatedState(ret->sref);
- sRef_setLen (ret->sref, sRef_getLen(e2->sref) - val);
- }
- }
- }
-
- /* Operator : - or -= */
- if ((lltok_getTok (op) == TMINUS) || (lltok_getTok (op) == SUB_ASSIGN)) {
- if (sRef_getSize(e2->sref) >= 0) {
- sRef_setSize (ret->sref, sRef_getSize(e2->sref) + val);
- sRef_setLen (ret->sref, sRef_getLen(e2->sref) + val);
- }
- }
- }
-
- /* end modifications */
-
- sRef_setNullError (ret->sref);
-
- /*
- ** Fixed for 2.2c: the alias state of ptr + int is dependent,
- ** since is points to storage that should not be deallocated
- ** through this pointer.
- */
-
- if (sRef_isOnly (ret->sref)
- || sRef_isFresh (ret->sref)) {
- sRef_setAliasKind (ret->sref, AK_DEPENDENT, exprNode_loc (ret));
- }