Module Name: src Committed By: rillig Date: Sun Jan 15 13:55:06 UTC 2023
Modified Files: src/tests/usr.bin/xlint/lint1: expr_sizeof.c Log Message: tests/lint: fix test for sizeof with variable-length array To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/expr_sizeof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/expr_sizeof.c diff -u src/tests/usr.bin/xlint/lint1/expr_sizeof.c:1.2 src/tests/usr.bin/xlint/lint1/expr_sizeof.c:1.3 --- src/tests/usr.bin/xlint/lint1/expr_sizeof.c:1.2 Sun Jan 15 13:30:04 2023 +++ src/tests/usr.bin/xlint/lint1/expr_sizeof.c Sun Jan 15 13:55:06 2023 @@ -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 @@ void 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)]; }