mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
[qfcc] Implement auto as per c23
That was surprisingly easy, which makes me worried I missed something.
This commit is contained in:
parent
cb4b073e47
commit
b9fd7a46af
4 changed files with 19 additions and 2 deletions
|
@ -120,6 +120,7 @@ typedef struct specifier_s {
|
|||
#define VEC_TYPE(type_name, base_type) extern type_t type_##type_name;
|
||||
#include "tools/qfcc/include/vec_types.h"
|
||||
|
||||
extern type_t type_auto;
|
||||
extern type_t type_invalid;
|
||||
extern type_t type_floatfield;
|
||||
|
||||
|
|
|
@ -587,6 +587,16 @@ initialize_def (symbol_t *sym, expr_t *init, defspace_t *space,
|
|||
sym->type = array_type (sym->type->t.array.type,
|
||||
num_elements (init));
|
||||
}
|
||||
if (sym->type == &type_auto) {
|
||||
if (init) {
|
||||
if (!(sym->type = get_type (init))) {
|
||||
sym->type = type_default;
|
||||
}
|
||||
} else {
|
||||
error (0, "'auto' requires an initialized data declaration");
|
||||
sym->type = type_default;
|
||||
}
|
||||
}
|
||||
sym->s.def = new_def (sym->name, sym->type, space, storage);
|
||||
reloc_attach_relocs (relocs, &sym->s.def->relocs);
|
||||
}
|
||||
|
|
|
@ -415,6 +415,7 @@ static keyword_t at_keywords[] = {
|
|||
{"static", STATIC },
|
||||
{"sizeof", SIZEOF },
|
||||
{"not", NOT },
|
||||
{"auto", TYPE_SPEC, .spec = { .type = &type_auto } },
|
||||
};
|
||||
|
||||
// These keywords require the QuakeForge VM to be of any use. ie, they cannot
|
||||
|
|
|
@ -79,6 +79,11 @@ type_t type_invalid = {
|
|||
.name = "invalid",
|
||||
};
|
||||
|
||||
type_t type_auto = {
|
||||
.type = ev_invalid,
|
||||
.name = "auto",
|
||||
};
|
||||
|
||||
#define VEC_TYPE(type_name, base_type) \
|
||||
type_t type_##type_name = { \
|
||||
.type = ev_##base_type, \
|
||||
|
@ -527,8 +532,8 @@ find_type (type_t *type)
|
|||
type_t *check;
|
||||
int i, count;
|
||||
|
||||
if (!type)
|
||||
return 0;
|
||||
if (!type || type == &type_auto)
|
||||
return type;
|
||||
|
||||
if (type->freeable) {
|
||||
switch (type->meta) {
|
||||
|
|
Loading…
Reference in a new issue