コード例 #1
0
static boolean passStructOnStack( // PASS A STRUCT/CLASS ON STACK
    PTREE arg,                  // - argument (CO_LIST)
    unsigned warning )          // - internal-data warning
{
    PTREE right;                // - right operand
    TYPE type;                  // - class type

    right = NodeRvalue( arg->u.subtree[1] );
    type = right->type;
    if( right->flags & PTF_CLASS_RVREF ) {
        if( right->op != PT_ERROR ) {
            PTREE temp = NodeTemporary( type );
            right = ClassDefaultCopyDiag( temp, right, &diagEllConv );
            if( right->op != PT_ERROR ) {
                right = NodeDtorExpr( right, temp->u.symcg.symbol );
                if( right->op != PT_ERROR ) {
                    right->type = type;
                    right = NodeFetch( right );
                    right->flags &= ~PTF_LVALUE;
                }
            }
        }
        if( right->op == PT_ERROR ) {
            arg->u.subtree[1] = right;
            PTreeErrorNode( arg );
            return FALSE;
        }
    }
    arg_finish( right, arg );
    if( TypeHasSpecialFields( type ) ) {
        PTreeWarnExpr( arg, warning );
    }
    return TRUE;
}
コード例 #2
0
void NodeWarnPtrTruncCast(      // WARN FOR CAST POINTER/REFERENCE TRUNCATION
    PTREE node )                // - node for warning
{
    PTreeWarnExpr( node, WARN_POINTER_TRUNCATION_CAST );
}
コード例 #3
0
ファイル: analretn.c プロジェクト: Ukusbobra/open-watcom-v2
static void checkAutoReturn(    // CHECK IF AUTOMATIC BEING RETURNED
    PTREE node,                 // - node to be checked
    TYPE ret_type )             // - return type
{
    TYPE func_ret;              // - type of function return
    SYMBOL func;                // - function called
    SYMBOL comped;              // - function being compiled
    PTREE expr;                 // - node for error
    TYPE refed;                 // - NULL ==> not reference

    comped = ScopeFunctionInProgress();
    if( SymIsGenedFunc( comped ) ) {
        return;
    }
    expr = node;
    refed = TypeReference( ret_type );
    for( ; ; ) {
        node = NodeRemoveCastsCommas( node );
        if( ( node->op == PT_SYMBOL )
          &&( SymIsAutomatic( node->u.symcg.symbol ) ) ) {
            if( NULL == refed ) {
                PTreeWarnExpr( expr, WARN_RET_ADDR_OF_AUTO );
            } else {
                PTreeErrorExpr( expr, ERR_RET_AUTO_REF );
            }
            break;
        } else if( NodeIsBinaryOp( node, CO_DOT )
                || NodeIsBinaryOp( node, CO_DOT_STAR ) ) {
            node = PTreeOpLeft( node );
        } else if( NodeIsUnaryOp( node, CO_ADDR_OF ) ) {
            node = PTreeOpLeft( node );
        } else if( NULL != refed ) {
            if( NodeIsBinaryOp( node, CO_DTOR ) ) {
                node = PTreeOpRight( node );
            } else if( NodeIsBinaryOp( node, CO_CALL_EXEC ) ) {
                node = PTreeOpLeft( PTreeOpLeft( node ) );
                if( node->op == PT_SYMBOL ) {
                    func = node->u.symcg.symbol;
                    if( SymIsCtor( func ) ) {
                        PTreeErrorExpr( expr, ERR_RET_AUTO_REF );
                    } else {
                        func_ret = SymFuncReturnType( func );
                        if( NULL != StructType( func_ret ) ) {
                            PTreeErrorExpr( expr, ERR_RET_AUTO_REF );
                        }
                    }
                }
                break;
            } else if( NodeIsBinaryOp( node, CO_CALL_EXEC_IND ) ) {
                func_ret = TypeFunctionCalled( NodeFuncForCall( node )->type );
                func_ret = func_ret->of;
                if( NULL != StructType( func_ret ) ) {
                    PTreeErrorExpr( expr, ERR_RET_AUTO_REF );
                }
                break;
            } else {
                break;
            }
        } else {
            break;
        }
    }
}