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: fix emitted type for arrays of unk...



details:   https://anonhg.NetBSD.org/src/rev/a6723e7e4c45
branches:  trunk
changeset: 375949:a6723e7e4c45
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon May 22 17:53:27 2023 +0000

description:
lint: fix emitted type for arrays of unknown size

diffstat:

 tests/usr.bin/xlint/lint1/emit.c      |  9 ++++-----
 tests/usr.bin/xlint/lint1/emit.exp-ln |  2 +-
 usr.bin/xlint/lint1/decl.c            |  7 ++++---
 usr.bin/xlint/lint1/init.c            |  5 +++--
 4 files changed, 12 insertions(+), 11 deletions(-)

diffs (86 lines):

diff -r a73c64976b9e -r a6723e7e4c45 tests/usr.bin/xlint/lint1/emit.c
--- a/tests/usr.bin/xlint/lint1/emit.c  Mon May 22 17:47:27 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.c  Mon May 22 17:53:27 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emit.c,v 1.16 2023/05/22 11:51:46 rillig Exp $ */
+/*     $NetBSD: emit.c,v 1.17 2023/05/22 17:53:27 rillig Exp $ */
 # 3 "emit.c"
 
 /*
@@ -309,10 +309,9 @@ struct compound_expression_in_initialize
 };
 
 /*
- * FIXME: The type that ends up in the .ln file is 'A0cC', which is wrong as it
- * has array size 0 instead of the correct 8.
- *
- * This is caused by cgram_declare being called before processing the
+ * Before decl.c 1.312 and init.c 1.242 from 2023-05-22, the type that ended up
+ * in the .ln file was 'A0cC', which was wrong as it had array size 0 instead
+ * of the correct 8.  That type had been taken too early, before looking at the
  * initializer.
  */
 const char array_of_unknown_size[] = "unknown";
diff -r a73c64976b9e -r a6723e7e4c45 tests/usr.bin/xlint/lint1/emit.exp-ln
--- a/tests/usr.bin/xlint/lint1/emit.exp-ln     Mon May 22 17:47:27 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/emit.exp-ln     Mon May 22 17:53:27 2023 +0000
@@ -82,4 +82,4 @@ 288u0.288x17declared_used_var
 289u0.289x16defined_used_var
 286d0.286d8use_varsF0V
 305d0.305d8compoundsT134compound_expression_in_initializer
-318d0.318d21array_of_unknown_sizeA0cC
+317d0.317d21array_of_unknown_sizeA8cC
diff -r a73c64976b9e -r a6723e7e4c45 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Mon May 22 17:47:27 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Mon May 22 17:53:27 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.312 2023/05/22 17:47:27 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.313 2023/05/22 17:53:27 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.312 2023/05/22 17:47:27 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.313 2023/05/22 17:53:27 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1992,7 +1992,8 @@ declare_extern(sym_t *dsym, bool has_ini
                 */
                bool rval = dsym->s_type->t_subt->t_tspec != VOID;
                outfdef(dsym, &dsym->s_def_pos, rval, false, NULL);
-       } else if (!is_compiler_builtin(dsym->s_name)) {
+       } else if (!is_compiler_builtin(dsym->s_name)
+           && !(has_initializer && dsym->s_type->t_incomplete_array)) {
                outsym(dsym, dsym->s_scl, dsym->s_def);
        }
 
diff -r a73c64976b9e -r a6723e7e4c45 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Mon May 22 17:47:27 2023 +0000
+++ b/usr.bin/xlint/lint1/init.c        Mon May 22 17:53:27 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.241 2023/04/22 17:49:15 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.242 2023/05/22 17:53:27 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: init.c,v 1.241 2023/04/22 17:49:15 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.242 2023/05/22 17:53:27 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -252,6 +252,7 @@ update_type_of_array_of_unknown_size(sym
        tp->t_incomplete_array = false;
        sym->s_type = tp;
        debug_step("completed array type is '%s'", type_name(sym->s_type));
+       outsym(sym, sym->s_scl, sym->s_def);
 }
 
 



Home | Main Index | Thread Index | Old Index