diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-12-07 18:44:58 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-12-07 18:44:58 -0500 |
| commit | 85d1507d8b7e0139135e040b7b4b23c02097a155 (patch) | |
| tree | 8eb7268aa29dd37846f16edbeb32c093efe1d63e /src/types.c | |
| parent | 43b0a91664fc0b9a5222805c68c3505fd9634689 (diff) | |
Consolidate logic for enums with and without tags with fields.
Diffstat (limited to 'src/types.c')
| -rw-r--r-- | src/types.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/types.c b/src/types.c index b34d8bf9..e3bf326c 100644 --- a/src/types.c +++ b/src/types.c @@ -701,8 +701,7 @@ type_t *get_field_type(type_t *t, const char *field_name) { DeclareMatch(e, t, EnumType); for (tag_t *tag = e->tags; tag; tag = tag->next) { if (!streq(field_name, tag->name)) continue; - if (tag->type != NULL && Match(tag->type, StructType)->fields) return Type(OptionalType, tag->type); - else return Type(OptionalType, EMPTY_TYPE); + return Type(OptionalType, tag->type); } return NULL; } @@ -835,10 +834,3 @@ type_t *_make_function_type(type_t *ret, int n, arg_t args[n]) { } return Type(FunctionType, .ret = ret, .args = &arg_pointers[0]); } - -PUREFUNC bool enum_has_fields(type_t *t) { - for (tag_t *e_tag = Match(t, EnumType)->tags; e_tag; e_tag = e_tag->next) { - if (e_tag->type != NULL && Match(e_tag->type, StructType)->fields) return true; - } - return false; -} |
