diff options
author | Michael Forney <mforney@mforney.org> | 2019-02-19 12:43:29 -0800 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-02-19 13:25:27 -0800 |
commit | 07ead54177dbbc28ce0665f0091f6be0940f5763 (patch) | |
tree | ab5c47e87a85c9ed05fb39006f0c9ae59eec7ef2 /type.c | |
parent | d13019290ee2e7f41369f1d31ce903efd26cfd05 (diff) |
Add missing lvalue conversions
typeintpromote and typeargpromote assume they are dealing with an
unqualified type, and return an incorrect result if they are given a
qualified one. So, add an assert here.
This was causing const integer types to get promoted to themselves due
to missing lvalue conversions.
Thanks to Andrew Chambers for the bug report and test case.
Diffstat (limited to 'type.c')
-rw-r--r-- | type.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -237,6 +237,7 @@ typeunqual(struct type *t, enum typequalifier *tq) struct type * typeintpromote(struct type *t) { + assert(t->kind != TYPEQUALIFIED); if (typeprop(t) & PROPINT && typerank(t) <= typerank(&typeint)) return t->size < typeint.size || t->basic.issigned ? &typeint : &typeuint; return t; @@ -245,6 +246,7 @@ typeintpromote(struct type *t) struct type * typeargpromote(struct type *t) { + assert(t->kind != TYPEQUALIFIED); if (t == &typefloat) return &typedouble; return typeintpromote(t); |