Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/VariableSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ VariableSelector::choose_var(vector<Variable *> vars,
eMatchType mt,
const vector<const Variable*>& invalid_vars,
bool no_bitfield,
bool no_expand_struct_union)
bool no_expand_struct_union,
bool no_union)
{
vector<Variable *> ok_vars;
vector<Variable *>::iterator i;
Expand All @@ -438,6 +439,8 @@ VariableSelector::choose_var(vector<Variable *> vars,
// skip any type mismatched var
if (no_bitfield && (*i)->isBitfield_)
continue;
if (no_union && (*i)->is_inside_union_field())
continue;
if (type && !type->match((*i)->type, mt)) {
continue;
}
Expand Down Expand Up @@ -844,16 +847,18 @@ VariableSelector::make_init_value(Effect::Access access, const CGContext &cg_con
vector<Variable*> vars = find_all_visible_vars(b);
vector<const Variable*> dummy;

const bool no_union = !CGOptions::take_union_field_addr();

Variable *var = NULL;
// b == NULL means we are generating init for globals
if (!b && CGOptions::ccomp()) {
get_all_array_vars(dummy);
var = choose_var(vars, access, cg_context, type, &qfer, eExact, dummy, true, true);
var = choose_var(vars, access, cg_context, type, &qfer, eExact, dummy, true, true, no_union);
}
else {
if (!CGOptions::addr_taken_of_locals())
get_all_local_vars(b, dummy);
var = choose_var(vars, access, cg_context, type, &qfer, eExact, dummy, true);
var = choose_var(vars, access, cg_context, type, &qfer, eExact, dummy, true, false, no_union);
}
ERROR_GUARD(NULL);

Expand Down
2 changes: 1 addition & 1 deletion src/VariableSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class VariableSelector
static const Variable* choose_visible_read_var(const Block* b, vector<const Variable*> written_vars, const Type* type, const vector<const Fact*>& facts);
static Variable* choose_var(vector<Variable *> vars, Effect::Access access,
const CGContext &cg_context, const Type* type, const CVQualifiers* qfer,
eMatchType mt, const vector<const Variable*>& invalid_vars, bool no_bitfield = false, bool no_expand_struct = false);
eMatchType mt, const vector<const Variable*>& invalid_vars, bool no_bitfield = false, bool no_expand_struct = false, bool no_union = false);
static Variable *select_deref_pointer(Effect::Access access, const CGContext &cg_context, const Type* type,
const CVQualifiers* qfer, const vector<const Variable*>& invalid_vars);
static Variable *SelectLoopCtrlVar(const CGContext &cg_context, const vector<const Variable*>& invalid_vars);
Expand Down