From: Wolfgang Bumiller Date: Thu, 3 Jan 2013 11:49:21 +0000 (+0100) Subject: Introducing TYPE_NOEXPR so that these undefined labels cannot be used on the expressi... X-Git-Tag: before-library~378 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=ae09831227b2a3f81335526208aaaf54e10d794b Introducing TYPE_NOEXPR so that these undefined labels cannot be used on the expression side of goto ternary expressions; ast_label now is TYPE_NOEXPR; we may consider setting ast_ifthen to that too unless we want ifthen to return a value... --- diff --git a/ast.c b/ast.c index 7d4b93d..b2b7064 100644 --- a/ast.c +++ b/ast.c @@ -831,6 +831,8 @@ ast_label* ast_label_new(lex_ctx ctx, const char *name, bool undefined) ast_instantiate(ast_label, ctx, ast_label_delete); ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_label_codegen); + self->expression.vtype = TYPE_NOEXPR; + self->name = util_strdup(name); self->irblock = NULL; self->gotos = NULL; diff --git a/gmqcc.h b/gmqcc.h index bdda81b..0bfe7ce 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -445,6 +445,7 @@ enum { TYPE_ARRAY , TYPE_NIL , /* it's its own type / untyped */ + TYPE_NOEXPR , /* simply invalid in expressions */ TYPE_COUNT }; diff --git a/ir.c b/ir.c index 9458038..afe4a40 100644 --- a/ir.c +++ b/ir.c @@ -44,7 +44,8 @@ const char *type_name[TYPE_COUNT] = { "union", "array", - "nil" + "nil", + "" }; size_t type_sizeof_[TYPE_COUNT] = { @@ -62,6 +63,7 @@ size_t type_sizeof_[TYPE_COUNT] = { 0, /* TYPE_UNION */ 0, /* TYPE_ARRAY */ 0, /* TYPE_NIL */ + 0, /* TYPE_NOESPR */ }; uint16_t type_store_instr[TYPE_COUNT] = { @@ -85,6 +87,7 @@ uint16_t type_store_instr[TYPE_COUNT] = { AINSTR_END, /* union */ AINSTR_END, /* array */ AINSTR_END, /* nil */ + AINSTR_END, /* noexpr */ }; uint16_t field_store_instr[TYPE_COUNT] = { @@ -108,6 +111,7 @@ uint16_t field_store_instr[TYPE_COUNT] = { AINSTR_END, /* union */ AINSTR_END, /* array */ AINSTR_END, /* nil */ + AINSTR_END, /* noexpr */ }; uint16_t type_storep_instr[TYPE_COUNT] = { @@ -131,6 +135,7 @@ uint16_t type_storep_instr[TYPE_COUNT] = { AINSTR_END, /* union */ AINSTR_END, /* array */ AINSTR_END, /* nil */ + AINSTR_END, /* noexpr */ }; uint16_t type_eq_instr[TYPE_COUNT] = { @@ -154,6 +159,7 @@ uint16_t type_eq_instr[TYPE_COUNT] = { AINSTR_END, /* union */ AINSTR_END, /* array */ AINSTR_END, /* nil */ + AINSTR_END, /* noexpr */ }; uint16_t type_ne_instr[TYPE_COUNT] = { @@ -177,6 +183,7 @@ uint16_t type_ne_instr[TYPE_COUNT] = { AINSTR_END, /* union */ AINSTR_END, /* array */ AINSTR_END, /* nil */ + AINSTR_END, /* noexpr */ }; uint16_t type_not_instr[TYPE_COUNT] = { @@ -200,6 +207,7 @@ uint16_t type_not_instr[TYPE_COUNT] = { AINSTR_END, /* union */ AINSTR_END, /* array */ AINSTR_END, /* nil */ + AINSTR_END, /* noexpr */ }; /* protos */