Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: fix test for sizeof wi...



details:   https://anonhg.NetBSD.org/src/rev/460ea96364ee
branches:  trunk
changeset: 373059:460ea96364ee
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 15 13:55:06 2023 +0000

description:
tests/lint: fix test for sizeof with variable-length array

diffstat:

 tests/usr.bin/xlint/lint1/expr_sizeof.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r 4962c38ebbd0 -r 460ea96364ee tests/usr.bin/xlint/lint1/expr_sizeof.c
--- a/tests/usr.bin/xlint/lint1/expr_sizeof.c   Sun Jan 15 13:30:04 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/expr_sizeof.c   Sun Jan 15 13:55:06 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expr_sizeof.c,v 1.2 2023/01/15 13:30:04 rillig Exp $   */
+/*     $NetBSD: expr_sizeof.c,v 1.3 2023/01/15 13:55:06 rillig Exp $   */
 # 3 "expr_sizeof.c"
 
 /*
@@ -62,7 +62,12 @@
 variable_length_array(int n)
 {
        int local_arr[n + 5];
-       /* FIXME: sizeof(local_arr) must be 20, not 4. */
+
+       /*
+        * Since the array length is not constant, it cannot be used in a
+        * typedef.  Code like this are already rejected by the compiler.  For
+        * simplicity, lint assumes that the array has length 1.
+        */
        /* expect+1: error: negative array dimension (-4) [20] */
        typedef int sizeof_local_arr[-(int)sizeof(local_arr)];
 }



Home | Main Index | Thread Index | Old Index