tests/lint: test packed and in-parameter declarations

This commit is contained in:
rillig 2023-08-01 19:52:15 +00:00
parent 762dda02dd
commit b525fc25f4
2 changed files with 19 additions and 2 deletions

View File

@ -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)];

View File

@ -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;
}