Module Name:    src
Committed By:   rillig
Date:           Fri Apr  1 20:38:37 UTC 2022

Modified Files:
        src/usr.bin/xlint/lint1: decl.c

Log Message:
lint: add debug logging for type declarators

This will help in fixing the wrong type in msg_347.c, as well as the
assertion failure for 'sizeof(int())'.


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/usr.bin/xlint/lint1/decl.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/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.254 src/usr.bin/xlint/lint1/decl.c:1.255
--- src/usr.bin/xlint/lint1/decl.c:1.254	Fri Apr  1 20:29:37 2022
+++ src/usr.bin/xlint/lint1/decl.c	Fri Apr  1 20:38:37 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.254 2022/04/01 20:29:37 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.255 2022/04/01 20:38:37 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.254 2022/04/01 20:29:37 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.255 2022/04/01 20:38:37 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1306,8 +1306,11 @@ add_pointer(sym_t *decl, qual_ptr *p)
 	tpp = &decl->s_type;
 	while (*tpp != NULL && *tpp != dcs->d_type)
 		tpp = &(*tpp)->t_subt;
-	if (*tpp == NULL)
+	if (*tpp == NULL) {
+		debug_step("add_pointer: unchanged '%s'",
+		    type_name(decl->s_type));
 		return decl;
+	}
 
 	while (p != NULL) {
 		*tpp = tp = block_zero_alloc(sizeof(*tp));
@@ -1319,6 +1322,7 @@ add_pointer(sym_t *decl, qual_ptr *p)
 		free(p);
 		p = next;
 	}
+	debug_step("add_pointer: '%s'", type_name(decl->s_type));
 	return decl;
 }
 
@@ -1334,8 +1338,11 @@ add_array(sym_t *decl, bool dim, int n)
 	tpp = &decl->s_type;
 	while (*tpp != NULL && *tpp != dcs->d_type)
 		tpp = &(*tpp)->t_subt;
-	if (*tpp == NULL)
+	if (*tpp == NULL) {
+		debug_step("add_array: unchanged '%s'",
+		    type_name(decl->s_type));
 		return decl;
+	}
 
 	*tpp = tp = block_zero_alloc(sizeof(*tp));
 	tp->t_tspec = ARRAY;
@@ -1353,6 +1360,7 @@ add_array(sym_t *decl, bool dim, int n)
 		setcomplete(tp, false);
 	}
 
+	debug_step("add_array: '%s'", type_name(decl->s_type));
 	return decl;
 }
 
@@ -1397,8 +1405,11 @@ add_function(sym_t *decl, sym_t *args)
 		 * may even be guaranteed to be NULL.
 		 */
 		tpp = &(*tpp)->t_subt;
-	if (*tpp == NULL)
+	if (*tpp == NULL) {
+		debug_step("add_function: unchanged '%s'",
+		    type_name(decl->s_type));
 		return decl;	/* see msg_347 */
+	}
 
 	*tpp = tp = block_zero_alloc(sizeof(*tp));
 	tp->t_tspec = FUNC;
@@ -1407,6 +1418,7 @@ add_function(sym_t *decl, sym_t *args)
 		tp->t_args = args;
 	tp->t_vararg = dcs->d_vararg;
 
+	debug_step("add_function: '%s'", type_name(decl->s_type));
 	return decl;
 }
 

Reply via email to