Module Name: src Committed By: christos Date: Thu Apr 17 18:23:18 UTC 2014
Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: - 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. To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.75 src/usr.bin/xlint/lint1/tree.c:1.76 --- src/usr.bin/xlint/lint1/tree.c:1.75 Tue Feb 18 17:01:36 2014 +++ src/usr.bin/xlint/lint1/tree.c Thu Apr 17 14:23:18 2014 @@ -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, 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, 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, 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;