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 Always set i_brace in the struct case.
details: https://anonhg.NetBSD.org/src/rev/e3aecb6e11eb
branches: trunk
changeset: 333887:e3aecb6e11eb
user: christos <christos%NetBSD.org@localhost>
date: Thu Nov 20 20:49:06 2014 +0000
description:
Always set i_brace in the struct case.
Cleanup some debugging.
diffstat:
usr.bin/xlint/lint1/init.c | 96 ++++++++++++++++++++++++++++-----------------
1 files changed, 60 insertions(+), 36 deletions(-)
diffs (truncated from 303 to 300 lines):
diff -r 6fb6b9190ade -r e3aecb6e11eb usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Thu Nov 20 20:48:33 2014 +0000
+++ b/usr.bin/xlint/lint1/init.c Thu Nov 20 20:49:06 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.25 2014/04/17 16:29:26 christos Exp $ */
+/* $NetBSD: init.c,v 1.26 2014/11/20 20:49:06 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.25 2014/04/17 16:29:26 christos Exp $");
+__RCSID("$NetBSD: init.c,v 1.26 2014/11/20 20:49:06 christos Exp $");
#endif
#include <stdlib.h>
@@ -89,7 +89,7 @@
{
namlist_t *nam = xcalloc(1, sizeof (namlist_t));
nam->n_name = sb->sb_name;
- DPRINTF(("memberpush = %s\n", nam->n_name));
+ DPRINTF(("%s: %s\n", __func__, nam->n_name));
if (namedmem == NULL) {
nam->n_prev = nam->n_next = nam;
namedmem = nam;
@@ -108,7 +108,7 @@
static void
memberpop()
{
- DPRINTF(("memberpop = %s\n", namedmem->n_name));
+ DPRINTF(("%s: %s\n", __func__, namedmem->n_name));
if (namedmem->n_next == namedmem) {
free(namedmem);
namedmem = NULL;
@@ -164,27 +164,34 @@
istk_t *istk;
sym_t *m;
- DPRINTF(("popi2(%s): brace=%d count=%d namedmem %d\n",
+ DPRINTF(("%s+(%s): brace=%d count=%d namedmem %d\n", __func__,
tyname(buf, sizeof(buf),
initstk->i_type ? initstk->i_type : initstk->i_subt),
initstk->i_brace, initstk->i_cnt, initstk->i_namedmem));
initstk = (istk = initstk)->i_nxt;
- if (initstk == NULL)
- LERROR("popi2()");
free(istk);
istk = initstk;
+ if (istk == NULL)
+ LERROR("popi2()");
+
+ DPRINTF(("%s-(%s): brace=%d count=%d namedmem %d\n", __func__,
+ tyname(buf, sizeof(buf),
+ initstk->i_type ? initstk->i_type : initstk->i_subt),
+ initstk->i_brace, initstk->i_cnt, initstk->i_namedmem));
istk->i_cnt--;
if (istk->i_cnt < 0)
LERROR("popi2()");
- DPRINTF(("popi2(): %d %s\n", istk->i_cnt,
+ DPRINTF(("%s(): %d %s\n", __func__, istk->i_cnt,
namedmem ? namedmem->n_name : "*null*"));
if (istk->i_cnt >= 0 && namedmem != NULL) {
- DPRINTF(("popi2(): %d %s %s\n", istk->i_cnt,
+ DPRINTF(("%s(): %d %s %s\n", __func__, istk->i_cnt,
tyname(buf, sizeof(buf), istk->i_type), namedmem->n_name));
for (m = istk->i_type->t_str->memb; m != NULL; m = m->s_nxt) {
+ DPRINTF(("%s(): pop [%s %s]\n", __func__,
+ namedmem->n_name, m->s_name));
if (m->s_field && m->s_name == unnamed)
continue;
if (strcmp(m->s_name, namedmem->n_name) == 0) {
@@ -195,6 +202,7 @@
}
}
error(101, namedmem->n_name);
+ DPRINTF(("%s(): namedmem %s\n", __func__, namedmem->n_name));
memberpop();
istk->i_namedmem = 1;
return;
@@ -209,6 +217,7 @@
m = istk->i_mem = istk->i_mem->s_nxt;
if (m == NULL)
LERROR("popi2()");
+ DPRINTF(("%s(): pop %s\n", __func__, m->s_name));
} while (m->s_field && m->s_name == unnamed);
istk->i_subt = m->s_type;
}
@@ -217,27 +226,32 @@
static void
popinit(int brace)
{
- DPRINTF(("popinit(%d)\n", brace));
+ DPRINTF(("%s(%d)\n", __func__, brace));
if (brace) {
/*
* Take all entries, including the first which requires
* a closing brace, from the stack.
*/
+ DPRINTF(("%s: brace\n", __func__));
do {
brace = initstk->i_brace;
+ DPRINTF(("%s: loop brace %d\n", __func__, brace));
popi2();
} while (!brace);
+ DPRINTF(("%s: brace done\n", __func__));
} else {
/*
* Take all entries which cannot be used for further
* initializers from the stack, but do this only if
* they do not require a closing brace.
*/
+ DPRINTF(("%s: no brace\n", __func__));
while (!initstk->i_brace &&
initstk->i_cnt == 0 && !initstk->i_nolimit) {
popi2();
}
+ DPRINTF(("%s: no brace done\n", __func__));
}
}
@@ -255,7 +269,7 @@
/* Extend an incomplete array type by one element */
if (istk->i_cnt == 0) {
- DPRINTF(("pushinit(extend) %s\n", tyname(buf, sizeof(buf),
+ DPRINTF(("%s(extend) %s\n", __func__, tyname(buf, sizeof(buf),
istk->i_type)));
/*
* Inside of other aggregate types must not be an incomplete
@@ -285,17 +299,17 @@
again:
istk = initstk;
- DPRINTF(("pushinit(%s)\n", tyname(buf, sizeof(buf), istk->i_type)));
+ DPRINTF(("%s(%s)\n", __func__, tyname(buf, sizeof(buf), istk->i_type)));
switch (istk->i_type->t_tspec) {
case ARRAY:
if (namedmem) {
- DPRINTF(("pushinit ARRAY %s brace=%d\n",
+ DPRINTF(("%s: ARRAY %s brace=%d\n", __func__,
namedmem->n_name, istk->i_brace));
goto pop;
} else if (istk->i_nxt->i_namedmem) {
- DPRINTF(("pushinit ARRAY brace=%d, namedmem=%d\n",
+ istk->i_brace = 1;
+ DPRINTF(("%s ARRAY brace=%d, namedmem=%d\n", __func__,
istk->i_brace, istk->i_nxt->i_namedmem));
- istk->i_brace = 1;
}
if (incompl(istk->i_type) && istk->i_nxt->i_nxt != NULL) {
@@ -307,7 +321,7 @@
istk->i_subt = istk->i_type->t_subt;
istk->i_nolimit = incompl(istk->i_type);
istk->i_cnt = istk->i_type->t_dim;
- DPRINTF(("elements array %s[%d] %s\n",
+ DPRINTF(("%s: elements array %s[%d] %s\n", __func__,
tyname(buf, sizeof(buf), istk->i_subt), istk->i_cnt,
namedmem ? namedmem->n_name : "*none*"));
break;
@@ -324,15 +338,15 @@
return;
}
cnt = 0;
- DPRINTF(("2. member lookup %s %s\n",
+ DPRINTF(("%s: 2. member lookup %s %s i_namedmem=%d\n", __func__,
tyname(buf, sizeof(buf), istk->i_type),
- namedmem ? namedmem->n_name : "*none*"));
+ namedmem ? namedmem->n_name : "*none*", istk->i_namedmem));
for (m = istk->i_type->t_str->memb; m != NULL; m = m->s_nxt) {
if (m->s_field && m->s_name == unnamed)
continue;
if (namedmem != NULL) {
- DPRINTF(("pushinit():[member:%s, looking:%s]\n",
- m->s_name, namedmem->n_name));
+ DPRINTF(("%s():[member:%s, looking:%s]\n",
+ __func__, m->s_name, namedmem->n_name));
if (strcmp(m->s_name, namedmem->n_name) == 0) {
cnt++;
break;
@@ -346,17 +360,22 @@
}
if (namedmem != NULL) {
if (m == NULL) {
- DPRINTF(("pushinit(): struct pop\n"));
+ DPRINTF(("%s(): struct pop\n", __func__));
goto pop;
- } else {
- istk->i_mem = m;
- istk->i_subt = m->s_type;
- }
+ }
+ istk->i_mem = m;
+ istk->i_subt = m->s_type;
istk->i_namedmem = 1;
- istk->i_brace = 1;
+ DPRINTF(("%s(): namedmem %s\n", __func__,
+ namedmem->n_name));
memberpop();
cnt = istk->i_type->t_tspec == STRUCT ? 2 : 1;
}
+ istk->i_brace = 1;
+ DPRINTF(("%s(): %s brace=%d\n", __func__,
+ tyname(buf, sizeof(buf),
+ istk->i_type ? istk->i_type : istk->i_subt),
+ istk->i_brace));
if (cnt == 0) {
/* cannot init. struct/union with no named member */
error(179);
@@ -367,7 +386,7 @@
break;
default:
if (namedmem) {
- DPRINTF(("pushinit(): pop\n"));
+ DPRINTF(("%s(): pop\n", __func__));
pop:
inxt = initstk->i_nxt;
free(istk);
@@ -415,7 +434,7 @@
{
char buf[64];
- DPRINTF(("nextinit(%d)\n", brace));
+ DPRINTF(("%s(%d)\n", __func__, brace));
if (!brace) {
if (initstk->i_type == NULL &&
!issclt(initstk->i_subt->t_tspec)) {
@@ -444,15 +463,20 @@
testinit();
if (!initerr)
pushinit();
- if (!initerr)
+ if (!initerr) {
initstk->i_brace = 1;
+ DPRINTF(("%s(): %p %s brace=%d\n", __func__,
+ namedmem, tyname(buf, sizeof(buf),
+ initstk->i_type ? initstk->i_type :
+ initstk->i_subt), initstk->i_brace));
+ }
}
}
void
initlbr(void)
{
- DPRINTF(("initlbr\n"));
+ DPRINTF(("%s\n", __func__));
if (initerr)
return;
@@ -476,7 +500,7 @@
void
initrbr(void)
{
- DPRINTF(("initrbr\n"));
+ DPRINTF(("%s\n", __func__));
if (initerr)
return;
@@ -497,8 +521,8 @@
char buf[64], sbuf[64];
#endif
- DPRINTF(("mkinit(%s %s)\n", tyname(buf, sizeof(buf), tn->tn_type),
- prtnode(sbuf, sizeof(sbuf), tn)));
+ DPRINTF(("%s(%s %s)\n", __func__, tyname(buf, sizeof(buf), tn->tn_type),
+ prtnode(sbuf, sizeof(sbuf), tn)));
if (initerr || tn == NULL)
return;
@@ -540,7 +564,7 @@
return;
initstk->i_cnt--;
- DPRINTF(("mkinit() cnt=%d tn=%p\n", initstk->i_cnt, tn));
+ DPRINTF(("%s() cnt=%d tn=%p\n", __func__, initstk->i_cnt, tn));
/* Create a temporary node for the left side. */
ln = tgetblk(sizeof (tnode_t));
ln->tn_op = NAME;
@@ -616,7 +640,7 @@
* the string.
*/
if (istk->i_subt != NULL && istk->i_subt->t_tspec == ARRAY) {
- DPRINTF(("strginit subt array\n"));
+ DPRINTF(("%s: subt array\n", __func__));
t = istk->i_subt->t_subt->t_tspec;
if (!((strg->st_tspec == CHAR &&
(t == CHAR || t == UCHAR || t == SCHAR)) ||
@@ -627,7 +651,7 @@
pushinit();
istk = initstk;
} else if (istk->i_type != NULL && istk->i_type->t_tspec == ARRAY) {
- DPRINTF(("strginit type array\n"));
+ DPRINTF(("%s: type array\n", __func__));
Home |
Main Index |
Thread Index |
Old Index