aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/c_type.h
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-04-13 09:45:28 +0200
committerlemon <lsof@mailbox.org>2026-04-13 09:45:28 +0200
commitb9de0c34a285aa0e3a7cfffb542732819adafd61 (patch)
tree55d54912f64f521da36240167934287ec26a4ee4 /src/c_type.h
parentdb576fab9f4eed8591c332d8353eed26c517ff36 (diff)
frontend: accept zero size arrays and empty aggregates
GNU extension. Previously was overloading arraylength==0 to mean unsized array, now they are distinct with the type flag TFUNKNOWN marking unsized arrays & aggregates.
Diffstat (limited to 'src/c_type.h')
-rw-r--r--src/c_type.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/c_type.h b/src/c_type.h
index 6f9a265..6ef1bc3 100644
--- a/src/c_type.h
+++ b/src/c_type.h
@@ -25,12 +25,12 @@ enum typeflagmask {
TFCHLDQUAL = 3,
TFCHLDPRIM = 1<<2,
TFCHLDISDAT = 1<<3,
+ TFUNKNOWN = 1<<4, /* array of unknown size, tagged type of unknown content */
};
-
typedef union Type {
struct {
uchar t; /* type tag */
- uchar flag;
+ uchar flag; /* enum typeflagmask */
union {
struct {
uchar child; /* prim type tag */
@@ -85,6 +85,7 @@ typedef struct {
typedef struct TypeData {
uchar t;
+ uchar flag;
ushort id;
union {
Type child;
@@ -127,6 +128,7 @@ uint typesize(Type);
uint typealign(Type);
Type mkptrtype(Type, int qual);
Type mkarrtype(Type t, int qual, uint n);
+Type mkunszarrtype(Type t, int qual);
Type mkfntype(Type ret, uint n, const Type *, bool kandr, bool variadic);
Type mktagtype(internstr name, TypeData *td);
bool getfield(FieldData *res, Type, internstr);
@@ -141,7 +143,7 @@ typechild(Type t)
if (t.t == TYENUM) return mktype(typedata[t.dat].backing);
if (t.flag & TFCHLDPRIM) return mktype(t.child);
if (t.flag & TFCHLDISDAT) {
- Type chld = mktype(typedata[t.dat].t, .dat = t.dat);
+ Type chld = mktype(typedata[t.dat].t, .flag = typedata[t.dat].flag, .dat = t.dat);
return chld;
}
return typedata[t.dat].child;