- add a function to dump a node
- better diagnostics on abort - allow converting a constant - initialize right node now that we trash memory this makes a difference. before it was NULL.
This commit is contained in:
parent
d0342ea7b6
commit
10e73b5c30
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tree.c,v 1.75 2014/02/18 22:01:36 christos Exp $ */
|
||||
/* $NetBSD: tree.c,v 1.76 2014/04/17 18:23:18 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: tree.c,v 1.75 2014/02/18 22:01:36 christos Exp $");
|
||||
__RCSID("$NetBSD: tree.c,v 1.76 2014/04/17 18:23:18 christos Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -89,6 +89,45 @@ static void precconf(tnode_t *);
|
|||
|
||||
extern sig_atomic_t fpe;
|
||||
|
||||
#if 0
|
||||
static char *
|
||||
dumpnode(char *buf, size_t len, tnode_t *tn) {
|
||||
const char *n = getopname(tn->tn_op);
|
||||
const char *s;
|
||||
char tbuf[256];
|
||||
|
||||
switch (tn->tn_op) {
|
||||
case NAME:
|
||||
s = tn->tn_sym->s_name;
|
||||
break;
|
||||
case CON:
|
||||
case STRING:
|
||||
s = "*"; /* todo */
|
||||
break;
|
||||
default:
|
||||
s = NULL;
|
||||
break;
|
||||
}
|
||||
char lb[1024];
|
||||
char rb[1024];
|
||||
|
||||
if (s == NULL && tn->tn_left != NULL)
|
||||
dumpnode(lb, sizeof(lb), tn->tn_left);
|
||||
else
|
||||
strcpy(lb, "(null)");
|
||||
|
||||
if (s == NULL && tn->tn_right != NULL)
|
||||
dumpnode(rb, sizeof(rb), tn->tn_right);
|
||||
else
|
||||
strcpy(rb, "(null)");
|
||||
|
||||
|
||||
snprintf(buf, len, "%s: (%s) = %s [%s, %s]", n,
|
||||
tyname(tbuf, sizeof(tbuf), tn->tn_type), s, lb, rb);
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Increase degree of reference.
|
||||
* This is most often used to change type "T" in type "pointer to T".
|
||||
|
@ -204,7 +243,7 @@ getnnode(sym_t *sym, int ntok)
|
|||
}
|
||||
|
||||
if (sym->s_kind != FVFT && sym->s_kind != FMOS)
|
||||
LERROR("getnnode()");
|
||||
LERROR("getnnode(%d)", sym->s_kind);
|
||||
|
||||
n = getnode();
|
||||
n->tn_type = sym->s_type;
|
||||
|
@ -1616,9 +1655,6 @@ convert(op_t op, int arg, type_t *tp, tnode_t *tn)
|
|||
tnode_t *ntn;
|
||||
tspec_t nt, ot, ost = NOTSPEC;
|
||||
|
||||
if (tn->tn_lvalue)
|
||||
LERROR("convert()");
|
||||
|
||||
nt = tp->t_tspec;
|
||||
if ((ot = tn->tn_type->t_tspec) == PTR)
|
||||
ost = tn->tn_type->t_subt->t_tspec;
|
||||
|
@ -1640,6 +1676,7 @@ convert(op_t op, int arg, type_t *tp, tnode_t *tn)
|
|||
ntn->tn_op = CVT;
|
||||
ntn->tn_type = tp;
|
||||
ntn->tn_cast = op == CVT;
|
||||
ntn->tn_right = NULL;
|
||||
if (tn->tn_op != CON || nt == VOID) {
|
||||
ntn->tn_left = tn;
|
||||
} else {
|
||||
|
@ -3569,7 +3606,9 @@ chkmisc(tnode_t *tn, int vctx, int tctx, int eqwarn, int fcall, int rvdisc,
|
|||
break;
|
||||
case CALL:
|
||||
if (ln->tn_op != AMPER || ln->tn_left->tn_op != NAME)
|
||||
LERROR("chkmisc()");
|
||||
LERROR("chkmisc(op=%s != %s || %s != %s)",
|
||||
getopname(ln->tn_op), getopname(AMPER),
|
||||
getopname(ln->tn_left->tn_op), getopname(NAME));
|
||||
if (!szof)
|
||||
outcall(tn, vctx || tctx, rvdisc);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue