Commit 755f9742 authored by Andreas Zwinkau's avatar Andreas Zwinkau
Browse files

Fix add_compound_member

The added unittest was failing and also x10i. Frontend moves global
entity into class for native method calls. liboo lowering moves it back
during vtable creation.

The issue is that "pmap_insert(map,key,NULL)" does not delete an entry,
so "pmap_contains(map,key)" afterwards does not return false. This
changes add_compound_member to assert a NULL value instead of a NULL

A similar error might be in ir/be/bechordal.c.
parent 92663003
......@@ -283,7 +283,7 @@ void set_entity_ld_ident(ir_entity *const ent, ident *const ld_ident)
&& get_entity_visibility(ent) != ir_visibility_private) {
pmap *globals = irp->globals;
pmap_insert(globals, old_ident, NULL);
assert(!pmap_contains(globals, ld_ident));
assert(NULL == pmap_get(ir_entity, globals, ld_ident));
pmap_insert(globals, ld_ident, ent);
......@@ -998,7 +998,7 @@ void add_compound_member(ir_type *type, ir_entity *entity)
ident *id = get_entity_ld_ident(entity);
pmap *globals = irp->globals;
/* Globals must have unique names. */
assert(!pmap_contains(globals, id));
assert(NULL == pmap_get(ir_entity, globals, id));
pmap_insert(globals, id, entity);
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include "firm.h"
#include "typerep.h"
#include "irprog.h"
int main(void)
ir_type *type = new_type_primitive(get_modeIs());
ident *id1 = new_id_from_str("foo");
ir_type *glob = get_glob_type();
ir_entity *x = new_global_entity(glob, id1, type, ir_visibility_external, IR_LINKAGE_DEFAULT);
assert(get_entity_owner(x) == glob);
ident *id2 = new_id_from_str("bar");
ir_type *cls = new_type_class(id2);
set_entity_owner(x, cls);
assert(get_entity_owner(x) == cls);
ir_entity *gx = ir_get_global(id1);
assert (NULL == gx);
set_entity_owner(x, glob);
assert(get_entity_owner(x) == glob);
return 0;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment