diff options
author | Michael Forney <mforney@mforney.org> | 2019-02-17 00:57:33 -0800 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-02-17 00:57:33 -0800 |
commit | 863fec184fdb150f4f8758cc68eb6a51f9a38dfe (patch) | |
tree | 63f78075067fcded66226eff2968663feb83ec73 /qbe.c | |
parent | 7d746860bda62c2f382bc0ac82d4d6c8cdf6c7b2 (diff) |
Improve old-style function declaration support
Implement typecompatible for types created with non-prototype function
declarations.
Require a function definition with parameter declaration list after a
declaration with a non-empty identifier list.
Detect function definitions with parameter declaration lists containing
types incompatible with the promoted types, and report an error for now.
Diffstat (limited to 'qbe.c')
-rw-r--r-- | qbe.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -337,6 +337,12 @@ mkglobal(char *name, bool private) return v; } +/* +XXX: If a function declared without a prototype is declared with a +parameter affected by default argument promotion, we need to emit a QBE +function with the promoted type and implicitly convert to the declared +parameter type before storing into the allocated memory for the parameter. +*/ struct function * mkfunc(char *name, struct type *t, struct scope *s) { @@ -355,6 +361,8 @@ mkfunc(char *name, struct type *t, struct scope *s) for (p = t->func.params; p; p = p->next) { if (!p->name) error(&tok.loc, "parameter name omitted in function definition"); + if (!t->func.isprototype && !typecompatible(p->type, typeargpromote(p->type))) + error(&tok.loc, "old-style function definition with parameter type incompatible with promoted type is not yet supported"); emittype(p->type); d = mkdecl(DECLOBJECT, p->type, LINKNONE); p->value = xmalloc(sizeof(*p->value)); |