From b525fc25f4f4531e1fba760aa5f06d1ea47bac77 Mon Sep 17 00:00:00 2001 From: rillig Date: Tue, 1 Aug 2023 19:52:15 +0000 Subject: [PATCH] tests/lint: test packed and in-parameter declarations --- tests/usr.bin/xlint/lint1/d_packed_structs.c | 7 ++++++- tests/usr.bin/xlint/lint1/decl.c | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/usr.bin/xlint/lint1/d_packed_structs.c b/tests/usr.bin/xlint/lint1/d_packed_structs.c index 5e1cf3789ccc..428cd6d82a6c 100644 --- a/tests/usr.bin/xlint/lint1/d_packed_structs.c +++ b/tests/usr.bin/xlint/lint1/d_packed_structs.c @@ -1,4 +1,4 @@ -/* $NetBSD: d_packed_structs.c,v 1.4 2023/03/28 14:44:34 rillig Exp $ */ +/* $NetBSD: d_packed_structs.c,v 1.5 2023/08/01 19:52:15 rillig Exp $ */ # 3 "d_packed_structs.c" /* packed tests */ @@ -39,3 +39,8 @@ struct y { }; int a[sizeof(struct y) - sizeof(struct x) - 1]; + +/* expect+1: error: negative array dimension (-9) [20] */ +typedef int sizeof_x[-(int)sizeof(struct x)]; +/* expect+1: error: negative array dimension (-16) [20] */ +typedef int sizeof_y[-(int)sizeof(struct y)]; diff --git a/tests/usr.bin/xlint/lint1/decl.c b/tests/usr.bin/xlint/lint1/decl.c index 48627c046eaa..0b26f51c4486 100644 --- a/tests/usr.bin/xlint/lint1/decl.c +++ b/tests/usr.bin/xlint/lint1/decl.c @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.25 2023/07/31 20:52:26 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.26 2023/08/01 19:52:15 rillig Exp $ */ # 3 "decl.c" /* @@ -229,3 +229,15 @@ symbol_type_in_unnamed_bit_field_member(void) int named_member; }; } + +// Symbols that are defined in the parameter list of a function definition can +// be accessed in the body of the function, even if they are nested. +int +get_x(struct point3d { struct point3d_number { int v; } x, y, z; } arg) +{ +/* expect-1: warning: dubious tag declaration 'struct point3d' [85] */ +/* expect-2: warning: dubious tag declaration 'struct point3d_number' [85] */ + static struct point3d local; + static struct point3d_number z; + return arg.x.v + local.x.v + z.v; +}