C++ (Cpp) assert Examples

C++ (Cpp) assert - 30 examples found. These are the top rated real world C++ (Cpp) examples of assert extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
File: ast.c Project: volth/ponyc
void ast_swap(ast_t* prev, ast_t* next)
{
    assert(prev->parent != NULL);
    assert(prev != next);

    if(next->parent != NULL)
        next = ast_dup(next);

    next->scope = prev->parent;
    next->parent = prev->parent;

    if(prev->parent->type == prev)
    {
        prev->parent->type = next;
    } else {
        ast_t* last = ast_previous(prev);

        if(last != NULL)
            last->sibling = next;
        else
            prev->parent->child = next;

        next->sibling = prev->sibling;
    }

    prev->parent = NULL;
    prev->sibling = NULL;
}
Example #2
0
int get_symbol_type(const Symbol * sym, Symbol ** type) {
    assert(sym->magic == SYMBOL_MAGIC);
    if (sym->address) {
        *type = NULL;
        return 0;
    }
    if (!sym->base && !sym->info) {
        DWORD tag = 0;
        DWORD index = 0;
        Symbol * res = alloc_symbol();
        *res = *sym;
        if (get_type_info(sym, TI_GET_SYMTAG, &tag) < 0) return -1;
        switch (tag) {
        case SymTagTypedef:
        case SymTagFunction:
        case SymTagPublicSymbol:
        case SymTagData:
        case SymTagFunctionArgType:
            if (get_type_info(sym, TI_GET_TYPE, &index) < 0) return -1;
            res->sym_class = SYM_CLASS_TYPE;
            res->index = index;
            *type = res;
            return 0;
        }
        assert(sym->sym_class == SYM_CLASS_UNKNOWN || sym->sym_class == SYM_CLASS_TYPE);
    }
    *type = (Symbol *)sym;
    return 0;
}
Example #3
0
/* Refreshes the stack of parent pointers in |trav|
   and updates its generation number. */
static void
trav_refresh (struct avl_traverser *trav)
{
    assert (trav != NULL);

    trav->avl_generation = trav->avl_table->avl_generation;

    if (trav->avl_node != NULL)
    {
        avl_comparison_func *cmp = trav->avl_table->avl_compare;
        void *param = trav->avl_table->avl_param;
        struct avl_node *node = trav->avl_node;
        struct avl_node *i;

        trav->avl_height = 0;
        for (i = trav->avl_table->avl_root; i != node; )
        {
            assert (trav->avl_height < AVL_MAX_HEIGHT);
            assert (i != NULL);

            trav->avl_stack[trav->avl_height++] = i;
            i = i->avl_link[cmp (node->avl_data, i->avl_data, param) > 0];
        }
    }
}
Example #4
0
void
expect_bounce_fail (void *server, void *client)
{
    const char *content = "12345678ABCDEFGH12345678abcdefgh";
    char buffer [32];

    //  Send message from client to server
    int rc = zmq_send (client, content, 32, ZMQ_SNDMORE);
    assert (rc == 32);
    rc = zmq_send (client, content, 32, 0);
    assert (rc == 32);

    //  Receive message at server side (should not succeed)
    int timeout = 150;
    rc = zmq_setsockopt (server, ZMQ_RCVTIMEO, &timeout, sizeof (int));
    assert (rc == 0);
    rc = zmq_recv (server, buffer, 32, 0);
    assert (rc == -1);
    assert (zmq_errno () == EAGAIN);

    //  Send message from server to client to test other direction
    rc = zmq_send (server, content, 32, ZMQ_SNDMORE);
    assert (rc == 32);
    rc = zmq_send (server, content, 32, 0);
    assert (rc == 32);

    //  Receive message at client side (should not succeed)
    rc = zmq_setsockopt (client, ZMQ_RCVTIMEO, &timeout, sizeof (int));
    assert (rc == 0);
    rc = zmq_recv (client, buffer, 32, 0);
    assert (rc == -1);
    assert (zmq_errno () == EAGAIN);
}
Example #5
0
void ccp_tr_gotdrt( ccp_action_record	*rec)
{
    ccp_db_header	*db;
    uint4	status;
    void		ccp_exitwm_attempt(), ccp_gotdrt_tick();


    db = rec->v.h;

    assert(!db->dirty_buffers_acquired);
    db->dirty_buffers_acquired = TRUE;

    assert(db->segment->nl->ccp_state == CCST_WRTGNT);
    db->segment->nl->ccp_state = CCST_DRTGNT;

    if (db->blocking_ast_received  &&  !db->tick_in_progress  &&  !db->quantum_expired)
    {
        status = sys$dclast(ccp_gotdrt_tick, db, PSL$C_USER);
        if (status != SS$_NORMAL)
            ccp_signal_cont(status);	/***** Is this reasonable? *****/
    }

    ccp_pndg_proc_wake(&db->flu_wait);
    status = sys$dclast(ccp_exitwm_attempt, db, PSL$C_USER);
    if (status != SS$_NORMAL)
        ccp_signal_cont(status);	/***** Is this reasonable? *****/

    return;
}
Example #6
0
/// \brief Add the section group and the group-child reference members.
void Resolver::maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom) {
    // First time adding a group?
    bool isFirstTime = _symbolTable.addGroup(atom);

    if (!isFirstTime) {
        // If duplicate symbols are allowed, select the first group.
        if (_context.getAllowDuplicates())
            return;
        auto *prevGroup = dyn_cast<DefinedAtom>(_symbolTable.findGroup(atom.name()));
        assert(prevGroup &&
               "Internal Error: The group atom could only be a defined atom");
        // The atoms should be of the same content type, reject invalid group
        // resolution behaviors.
        if (atom.contentType() == prevGroup->contentType())
            return;
        llvm::errs() << "SymbolTable: error while merging " << atom.name()
                     << "\n";
        llvm::report_fatal_error("duplicate symbol error");
        return;
    }

    for (const Reference *r : atom) {
        if (r->kindNamespace() == lld::Reference::KindNamespace::all &&
                r->kindValue() == lld::Reference::kindGroupChild) {
            const DefinedAtom *target = dyn_cast<DefinedAtom>(r->target());
            assert(target && "Internal Error: kindGroupChild references need to "
                   "be associated with Defined Atoms only");
            _atoms.push_back(target);
            _symbolTable.add(*target);
        }
    }
}