Skip to content

Commit

Permalink
enum subtype default value should be from subtype'left, not base type
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchsm committed Oct 12, 2015
1 parent dc8aaec commit f0a3871
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/common.c
Expand Up @@ -552,7 +552,14 @@ tree_t make_default_value(type_t type, const loc_t *loc)
return type_dim(type, 0).left;

case T_ENUM:
return make_ref(type_enum_literal(base, 0));
{
int64_t val = 0;
const bool folded = folded_int(type_dim(type, 0).left, &val);
if (folded)
return make_ref(type_enum_literal(base, (unsigned) val));
else
return type_dim(type, 0).left;
}

case T_RECORD:
{
Expand Down

0 comments on commit f0a3871

Please sign in to comment.