lint1: add test for initializing nested structs
Discovered in var.c 1.774 from 2020-12-28.
This commit is contained in:
parent
05e935016b
commit
69ccb624e9
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.17 2020/12/28 09:58:56 rillig Exp $
|
||||
# $NetBSD: Makefile,v 1.18 2020/12/28 10:22:21 rillig Exp $
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
@ -60,6 +60,7 @@ FILES+= d_nested_structs.c
|
||||
FILES+= d_nolimit_init.c
|
||||
FILES+= d_packed_structs.c
|
||||
FILES+= d_shift_to_narrower_type.c
|
||||
FILES+= d_struct_init_nested.c
|
||||
FILES+= d_type_conv1.c
|
||||
FILES+= d_type_conv1.exp
|
||||
FILES+= d_type_conv2.c
|
||||
|
59
tests/usr.bin/xlint/lint1/d_struct_init_nested.c
Normal file
59
tests/usr.bin/xlint/lint1/d_struct_init_nested.c
Normal file
@ -0,0 +1,59 @@
|
||||
# 2 "d_struct_init_nested.c"
|
||||
|
||||
typedef enum O1 { O1C = 101 } O1;
|
||||
typedef enum O2 { O2C = 102 } O2;
|
||||
typedef enum O3 { O3C = 103 } O3;
|
||||
typedef enum I1 { I1C = 201 } I1;
|
||||
typedef enum I2 { I2C = 202 } I2;
|
||||
|
||||
struct Inner1 {
|
||||
I1 i1;
|
||||
};
|
||||
|
||||
struct Outer3Inner1 {
|
||||
O1 o1;
|
||||
struct Inner1 inner;
|
||||
O3 o3;
|
||||
};
|
||||
|
||||
O1
|
||||
funcOuter3Inner1(void)
|
||||
{
|
||||
struct Inner1 inner = {
|
||||
I1C
|
||||
};
|
||||
struct Outer3Inner1 o3i1 = {
|
||||
O1C,
|
||||
inner,
|
||||
O3C
|
||||
};
|
||||
|
||||
return o3i1.o1;
|
||||
}
|
||||
|
||||
struct Inner2 {
|
||||
I1 i1;
|
||||
I2 i2;
|
||||
};
|
||||
|
||||
struct Outer3Inner2 {
|
||||
O1 o1;
|
||||
struct Inner2 inner;
|
||||
O3 o3;
|
||||
};
|
||||
|
||||
O1
|
||||
funcOuter3Inner2(void)
|
||||
{
|
||||
struct Inner2 inner = {
|
||||
I1C,
|
||||
I2C
|
||||
};
|
||||
struct Outer3Inner2 o3i2 = {
|
||||
O1C,
|
||||
inner,
|
||||
O3C
|
||||
};
|
||||
|
||||
return o3i2.o1;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: t_integration.sh,v 1.6 2020/12/28 09:58:56 rillig Exp $
|
||||
# $NetBSD: t_integration.sh,v 1.7 2020/12/28 10:22:21 rillig Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
@ -71,6 +71,8 @@ test_case check_valid c9x_recursive_init "Checks C9X struct/union member" \
|
||||
"init, with nested union and trailing member"
|
||||
test_case check_valid nested_structs "Checks nested structs"
|
||||
test_case check_valid packed_structs "Checks packed structs"
|
||||
test_case check_invalid struct_init_nested \
|
||||
"Initialization of nested structures"
|
||||
|
||||
test_case check_valid cast_init "Checks cast initialization"
|
||||
test_case check_valid cast_init2 "Checks cast initialization as the rhs of a" \
|
||||
|
Loading…
Reference in New Issue
Block a user