From 01c8aaae8ce0460b8b0f7305894d8be44d53fd5a Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 19 Jul 2012 09:59:17 +0900 Subject: [PATCH] Add some error checking for attaching identifiers. --- tools/qfcc/source/dags.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/qfcc/source/dags.c b/tools/qfcc/source/dags.c index 1c8dddabd..1500bfc86 100644 --- a/tools/qfcc/source/dags.c +++ b/tools/qfcc/source/dags.c @@ -221,9 +221,31 @@ dagnode_match (const dagnode_t *n, const daglabel_t *op, return 1; } +static int +op_is_identifer (operand_t *op) +{ + while (op->op_type == op_alias) + op = op->o.alias; + if (op->op_type == op_pointer) + return 1; + if (op->op_type == op_temp) + return 1; + if (op->op_type != op_symbol) + return 0; + if (op->o.symbol->sy_type != sy_var) + return 0; + return 1; +} + static void dagnode_attach_label (dagnode_t *n, daglabel_t *l) { + if (!l->op) + internal_error (0, "attempt to attach operator label to dagnode " + "identifers"); + if (!op_is_identifer (l->op)) + internal_error (0, "attempt to attach non-identifer label to dagnode " + "identifers"); if (n->identifiers) n->identifiers->prev = &l->next; l->next = n->identifiers;