Commit 09954cdb authored by Matthias Braun's avatar Matthias Braun
Browse files

Fix ir_visibility_external_private handling

parent 13142797
......@@ -97,9 +97,8 @@ static void visit_segment(ir_type *segment)
{
for (int i = 0, n = get_compound_n_members(segment); i < n; ++i) {
ir_entity *entity = get_compound_member(segment, i);
if (get_entity_visibility(entity) != ir_visibility_external
&& !(get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER)
&& !(get_entity_linkage(entity) & IR_LINKAGE_NO_CODEGEN))
if (!entity_is_externally_visible(entity)
&& !(get_entity_linkage(entity) & IR_LINKAGE_NO_CODEGEN))
continue;
visit_entity(entity);
......
......@@ -856,8 +856,16 @@ void (set_entity_dbg_info)(ir_entity *ent, dbg_info *db)
int entity_is_externally_visible(const ir_entity *entity)
{
return get_entity_visibility(entity) != ir_visibility_local
|| (get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER);
ir_visibility visibility = get_entity_visibility(entity);
switch (visibility) {
case ir_visibility_local:
case ir_visibility_private:
return get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER;
case ir_visibility_external:
case ir_visibility_external_private:
return true;
}
panic("Invalid visibility for entity %+F", entity);
}
int entity_has_definition(const ir_entity *entity)
......
......@@ -197,13 +197,20 @@ static bool check_initializer(const ir_initializer_t *initializer,
return false;
}
static bool is_externally_visible(const ir_entity *entity)
{
ir_visibility visibility = get_entity_visibility(entity);
return visibility == ir_visibility_external
|| visibility == ir_visibility_external_private;
}
static bool check_external_linkage(const ir_entity *entity, ir_linkage linkage,
const char *linkage_name)
{
bool fine = true;
if ((get_entity_linkage(entity) & linkage) == 0)
return true;
if (get_entity_visibility(entity) != ir_visibility_external) {
if (!is_externally_visible(entity)) {
report_error("entity %+F has IR_LINKAGE_%s but is not externally visible", entity, linkage_name);
fine = false;
}
......@@ -232,7 +239,7 @@ int check_entity(const ir_entity *entity)
report_error("entity %+F has IR_LINKAGE_NO_CODEGEN but has no ir-graph anyway", entity);
fine = false;
}
if (get_entity_visibility(entity) != ir_visibility_external) {
if (!is_externally_visible(entity)) {
report_error("entity %+F has IR_LINKAGE_NO_CODEGEN but is not externally visible", entity);
fine = false;
}
......
Markdown is supported
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