aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-03-15 12:33:44 +0100
committerlemon <lsof@mailbox.org>2026-03-15 12:34:02 +0100
commit1e98f81dca72530198e4c4fd01012d459bc28316 (patch)
tree0ebb8eabff1f457a40fc1263fb975afc4b8d0f73
parentb4caa5393f7a8ac5505c2892b85beb061196b78e (diff)
c: default enum to unsigned int backing type
Matches GCC behavior.
-rw-r--r--c/c.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/c/c.c b/c/c.c
index 4a461b9..63c3f7f 100644
--- a/c/c.c
+++ b/c/c.c
@@ -2174,7 +2174,9 @@ buildenum(struct comp *cm, internstr name, const struct span *span, int id)
}
td.backing = 0;
- for (int t = TYINT; t <= TYUVLONG; ++t) {
+ if (minv >= 0 && maxv <= ~0u) {
+ td.backing = TYUINT;
+ } else for (int t = TYINT; t <= TYUVLONG; ++t) {
inttyminmax(&tymin, &tymax, t);
if (minv >= tymin && maxv <= tymax) {
td.backing = t;