Introducing TYPE_NOEXPR so that these undefined labels cannot be used on the expressi...
authorWolfgang Bumiller <blub@speed.at>
Thu, 3 Jan 2013 11:49:21 +0000 (12:49 +0100)
committerWolfgang Bumiller <blub@speed.at>
Thu, 3 Jan 2013 11:49:21 +0000 (12:49 +0100)
ast.c
gmqcc.h
ir.c

diff --git a/ast.c b/ast.c
index 7d4b93dd28aa1c4acf254cbbe035491644a4a83e..b2b7064d8d43d6a47cfec1831b16c07ed4b6fec5 100644 (file)
--- 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 bdda81b8b14ffd24dfbcbe60d0c2ac533bffa3d4..0bfe7ce23c0a902d4585c406bbe6506e204a0793 100644 (file)
--- 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 9458038dd18522ba7378b41d0957200f5fcba5c2..afe4a40d1d5258988dac2e665f43c75a37faca21 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -44,7 +44,8 @@ const char *type_name[TYPE_COUNT] = {
     "union",
     "array",
 
-    "nil"
+    "nil",
+    "<no-expression>"
 };
 
 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 */