Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 - add a function to dump a node



details:   https://anonhg.NetBSD.org/src/rev/68f60efb5e28
branches:  trunk
changeset: 328777:68f60efb5e28
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Apr 17 18:23:18 2014 +0000

description:
- 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.

diffstat:

 usr.bin/xlint/lint1/tree.c |  53 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 46 insertions(+), 7 deletions(-)

diffs (102 lines):

diff -r 2f8fc7548322 -r 68f60efb5e28 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Thu Apr 17 18:17:09 2014 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Thu Apr 17 18:23:18 2014 +0000
@@ -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 @@
 
 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 @@
        }
 
        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 @@
        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 @@
        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 @@
                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;



Home | Main Index | Thread Index | Old Index