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 lint: add debug logging for initializing...
details: https://anonhg.NetBSD.org/src/rev/0cd0e3b309f3
branches: trunk
changeset: 959669:0cd0e3b309f3
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Feb 21 14:19:27 2021 +0000
description:
lint: add debug logging for initializing an array of unknown size
It is possible that the type name 'array[unknown_size]' may spill into
the user-visible diagnostics. The current test suite does not cover
such a case. Anyway, saying 'array[unknown_size]' is still better than
saying 'array[0]', which would be misleading.
diffstat:
tests/usr.bin/xlint/lint1/d_c99_init.c | 5 ++++-
usr.bin/xlint/common/tyname.c | 11 +++++++++--
usr.bin/xlint/lint1/init.c | 10 ++++++----
3 files changed, 19 insertions(+), 7 deletions(-)
diffs (88 lines):
diff -r a5ed5f867ee4 -r 0cd0e3b309f3 tests/usr.bin/xlint/lint1/d_c99_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_init.c Sun Feb 21 14:02:36 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c Sun Feb 21 14:19:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: d_c99_init.c,v 1.5 2021/02/21 13:10:57 rillig Exp $ */
+/* $NetBSD: d_c99_init.c,v 1.6 2021/02/21 14:19:27 rillig Exp $ */
# 3 "d_c99_init.c"
/*
@@ -50,3 +50,6 @@
// FIXME: message 185 needs to be reworded to "cannot initialize '%s' from '%s'".
use(&arg);
}
+
+// See initstack_push, 'extending array of unknown size'.
+const int primes[] = { 2, 3, 5, 7, 9 };
diff -r a5ed5f867ee4 -r 0cd0e3b309f3 usr.bin/xlint/common/tyname.c
--- a/usr.bin/xlint/common/tyname.c Sun Feb 21 14:02:36 2021 +0000
+++ b/usr.bin/xlint/common/tyname.c Sun Feb 21 14:19:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tyname.c,v 1.30 2021/02/21 10:28:32 rillig Exp $ */
+/* $NetBSD: tyname.c,v 1.31 2021/02/21 14:19:27 rillig Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.30 2021/02/21 10:28:32 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.31 2021/02/21 14:19:27 rillig Exp $");
#endif
#include <limits.h>
@@ -366,7 +366,14 @@
buf_add(&buf, " of ");
buf_add(&buf, type_name(tp->t_subt));
buf_add(&buf, "[");
+#ifdef t_str /* lint1 */
+ if (tp->t_incomplete_array)
+ buf_add(&buf, "unknown_size");
+ else
+ buf_add_int(&buf, tp->t_dim);
+#else
buf_add_int(&buf, tp->t_dim);
+#endif
buf_add(&buf, "]");
break;
case FUNC:
diff -r a5ed5f867ee4 -r 0cd0e3b309f3 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Sun Feb 21 14:02:36 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Sun Feb 21 14:19:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.84 2021/02/21 14:02:36 rillig Exp $ */
+/* $NetBSD: init.c,v 1.85 2021/02/21 14:19:27 rillig 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.84 2021/02/21 14:02:36 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.85 2021/02/21 14:19:27 rillig Exp $");
#endif
#include <stdlib.h>
@@ -466,16 +466,18 @@
/* Extend an incomplete array type by one element */
if (istk->i_remaining == 0) {
- debug_step("(extend) %s", type_name(istk->i_type));
/*
* Inside of other aggregate types must not be an incomplete
* type.
*/
lint_assert(istk->i_enclosing->i_enclosing == NULL);
+ lint_assert(istk->i_type->t_tspec == ARRAY);
+ debug_step("extending array of unknown size '%s'",
+ type_name(istk->i_type));
istk->i_remaining = 1;
- lint_assert(istk->i_type->t_tspec == ARRAY);
istk->i_type->t_dim++;
setcomplete(istk->i_type, true);
+ debug_step("extended type is '%s'", type_name(istk->i_type));
}
lint_assert(istk->i_remaining > 0);
Home |
Main Index |
Thread Index |
Old Index