lint: demonstrate bug in handling of nested C9X struct initializersdiff -r1.1005 -r1.1006 src/distrib/sets/lists/tests/mi
(rillig)
--- src/distrib/sets/lists/tests/mi 2021/01/01 01:07:07 1.1005
+++ src/distrib/sets/lists/tests/mi 2021/01/01 16:50:47 1.1006
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: mi,v 1.1005 2021/01/01 01:07:07 rillig Exp $ | 1 | # $NetBSD: mi,v 1.1006 2021/01/01 16:50:47 rillig Exp $ | |
2 | # | 2 | # | |
3 | # Note: don't delete entries from here - mark them as "obsolete" instead. | 3 | # Note: don't delete entries from here - mark them as "obsolete" instead. | |
4 | # | 4 | # | |
5 | ./etc/mtree/set.tests tests-sys-root | 5 | ./etc/mtree/set.tests tests-sys-root | |
6 | ./usr/libdata/debug/usr/tests tests-base-debug compattestdir | 6 | ./usr/libdata/debug/usr/tests tests-base-debug compattestdir | |
7 | ./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf | 7 | ./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf | |
8 | ./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf | 8 | ./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf | |
9 | ./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf | 9 | ./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf | |
10 | ./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf | 10 | ./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf | |
11 | ./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf | 11 | ./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf | |
12 | ./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete | 12 | ./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete | |
13 | ./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete | 13 | ./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete | |
14 | ./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete | 14 | ./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete | |
@@ -5783,26 +5783,28 @@ | @@ -5783,26 +5783,28 @@ | |||
5783 | ./usr/tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.exp tests-usr.bin-tests compattestfile,atf | 5783 | ./usr/tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.exp tests-usr.bin-tests compattestfile,atf | |
5784 | ./usr/tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c tests-usr.bin-tests compattestfile,atf | 5784 | ./usr/tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c tests-usr.bin-tests compattestfile,atf | |
5785 | ./usr/tests/usr.bin/xlint/lint1/d_fold_test.c tests-usr.bin-tests compattestfile,atf | 5785 | ./usr/tests/usr.bin/xlint/lint1/d_fold_test.c tests-usr.bin-tests compattestfile,atf | |
5786 | ./usr/tests/usr.bin/xlint/lint1/d_fold_test.exp tests-usr.bin-tests compattestfile,atf | 5786 | ./usr/tests/usr.bin/xlint/lint1/d_fold_test.exp tests-usr.bin-tests compattestfile,atf | |
5787 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c tests-usr.bin-tests compattestfile,atf | 5787 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c tests-usr.bin-tests compattestfile,atf | |
5788 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c tests-usr.bin-tests compattestfile,atf | 5788 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c tests-usr.bin-tests compattestfile,atf | |
5789 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c tests-usr.bin-tests compattestfile,atf | 5789 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c tests-usr.bin-tests compattestfile,atf | |
5790 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.c tests-usr.bin-tests compattestfile,atf | 5790 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.c tests-usr.bin-tests compattestfile,atf | |
5791 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.exp tests-usr.bin-tests compattestfile,atf | 5791 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_extension.exp tests-usr.bin-tests compattestfile,atf | |
5792 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_func.c tests-usr.bin-tests compattestfile,atf | 5792 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_func.c tests-usr.bin-tests compattestfile,atf | |
5793 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c tests-usr.bin-tests compattestfile,atf | 5793 | ./usr/tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c tests-usr.bin-tests compattestfile,atf | |
5794 | ./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.c tests-usr.bin-tests compattestfile,atf | 5794 | ./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.c tests-usr.bin-tests compattestfile,atf | |
5795 | ./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.exp tests-usr.bin-tests compattestfile,atf | 5795 | ./usr/tests/usr.bin/xlint/lint1/d_incorrect_array_size.exp tests-usr.bin-tests compattestfile,atf | |
5796 | ./usr/tests/usr.bin/xlint/lint1/d_init_pop_member.c tests-usr.bin-tests compattestfile,atf | |||
5797 | ./usr/tests/usr.bin/xlint/lint1/d_init_pop_member.exp tests-usr.bin-tests compattestfile,atf | |||
5796 | ./usr/tests/usr.bin/xlint/lint1/d_long_double_int.c tests-usr.bin-tests compattestfile,atf | 5798 | ./usr/tests/usr.bin/xlint/lint1/d_long_double_int.c tests-usr.bin-tests compattestfile,atf | |
5797 | ./usr/tests/usr.bin/xlint/lint1/d_long_double_int.exp tests-usr.bin-tests compattestfile,atf | 5799 | ./usr/tests/usr.bin/xlint/lint1/d_long_double_int.exp tests-usr.bin-tests compattestfile,atf | |
5798 | ./usr/tests/usr.bin/xlint/lint1/d_nested_structs.c tests-usr.bin-tests compattestfile,atf | 5800 | ./usr/tests/usr.bin/xlint/lint1/d_nested_structs.c tests-usr.bin-tests compattestfile,atf | |
5799 | ./usr/tests/usr.bin/xlint/lint1/d_nolimit_init.c tests-usr.bin-tests compattestfile,atf | 5801 | ./usr/tests/usr.bin/xlint/lint1/d_nolimit_init.c tests-usr.bin-tests compattestfile,atf | |
5800 | ./usr/tests/usr.bin/xlint/lint1/d_packed_structs.c tests-usr.bin-tests compattestfile,atf | 5802 | ./usr/tests/usr.bin/xlint/lint1/d_packed_structs.c tests-usr.bin-tests compattestfile,atf | |
5801 | ./usr/tests/usr.bin/xlint/lint1/d_return_type.c tests-usr.bin-tests compattestfile,atf | 5803 | ./usr/tests/usr.bin/xlint/lint1/d_return_type.c tests-usr.bin-tests compattestfile,atf | |
5802 | ./usr/tests/usr.bin/xlint/lint1/d_return_type.exp tests-usr.bin-tests compattestfile,atf | 5804 | ./usr/tests/usr.bin/xlint/lint1/d_return_type.exp tests-usr.bin-tests compattestfile,atf | |
5803 | ./usr/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c tests-usr.bin-tests compattestfile,atf | 5805 | ./usr/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c tests-usr.bin-tests compattestfile,atf | |
5804 | ./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.c tests-usr.bin-tests compattestfile,atf | 5806 | ./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.c tests-usr.bin-tests compattestfile,atf | |
5805 | ./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp tests-usr.bin-tests compattestfile,atf | 5807 | ./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp tests-usr.bin-tests compattestfile,atf | |
5806 | ./usr/tests/usr.bin/xlint/lint1/d_type_conv1.c tests-usr.bin-tests compattestfile,atf | 5808 | ./usr/tests/usr.bin/xlint/lint1/d_type_conv1.c tests-usr.bin-tests compattestfile,atf | |
5807 | ./usr/tests/usr.bin/xlint/lint1/d_type_conv1.exp tests-usr.bin-tests compattestfile,atf | 5809 | ./usr/tests/usr.bin/xlint/lint1/d_type_conv1.exp tests-usr.bin-tests compattestfile,atf | |
5808 | ./usr/tests/usr.bin/xlint/lint1/d_type_conv2.c tests-usr.bin-tests compattestfile,atf | 5810 | ./usr/tests/usr.bin/xlint/lint1/d_type_conv2.c tests-usr.bin-tests compattestfile,atf |
--- src/tests/usr.bin/xlint/lint1/Makefile 2021/01/01 01:07:08 1.23
+++ src/tests/usr.bin/xlint/lint1/Makefile 2021/01/01 16:50:47 1.24
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: Makefile,v 1.23 2021/01/01 01:07:08 rillig Exp $ | 1 | # $NetBSD: Makefile,v 1.24 2021/01/01 16:50:47 rillig Exp $ | |
2 | 2 | |||
3 | NOMAN= # defined | 3 | NOMAN= # defined | |
4 | 4 | |||
5 | .include <bsd.own.mk> | 5 | .include <bsd.own.mk> | |
6 | 6 | |||
7 | TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1 | 7 | TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1 | |
8 | 8 | |||
9 | TESTS_SH= t_integration | 9 | TESTS_SH= t_integration | |
10 | 10 | |||
11 | FILESDIR= ${TESTSDIR} | 11 | FILESDIR= ${TESTSDIR} | |
12 | FILES+= d_alignof.c | 12 | FILES+= d_alignof.c | |
13 | FILES+= d_bltinoffsetof.c | 13 | FILES+= d_bltinoffsetof.c | |
14 | FILES+= d_c99_anon_struct.c | 14 | FILES+= d_c99_anon_struct.c | |
@@ -51,26 +51,28 @@ FILES+= d_decl_old_style_arguments.c | @@ -51,26 +51,28 @@ FILES+= d_decl_old_style_arguments.c | |||
51 | FILES+= d_decl_old_style_arguments.exp | 51 | FILES+= d_decl_old_style_arguments.exp | |
52 | FILES+= d_ellipsis_in_switch.c | 52 | FILES+= d_ellipsis_in_switch.c | |
53 | FILES+= d_fold_test.c | 53 | FILES+= d_fold_test.c | |
54 | FILES+= d_fold_test.exp | 54 | FILES+= d_fold_test.exp | |
55 | FILES+= d_gcc_compound_statements1.c | 55 | FILES+= d_gcc_compound_statements1.c | |
56 | FILES+= d_gcc_compound_statements2.c | 56 | FILES+= d_gcc_compound_statements2.c | |
57 | FILES+= d_gcc_compound_statements3.c | 57 | FILES+= d_gcc_compound_statements3.c | |
58 | FILES+= d_gcc_extension.c | 58 | FILES+= d_gcc_extension.c | |
59 | FILES+= d_gcc_extension.exp | 59 | FILES+= d_gcc_extension.exp | |
60 | FILES+= d_gcc_func.c | 60 | FILES+= d_gcc_func.c | |
61 | FILES+= d_gcc_variable_array_init.c | 61 | FILES+= d_gcc_variable_array_init.c | |
62 | FILES+= d_incorrect_array_size.c | 62 | FILES+= d_incorrect_array_size.c | |
63 | FILES+= d_incorrect_array_size.exp | 63 | FILES+= d_incorrect_array_size.exp | |
64 | FILES+= d_init_pop_member.c | |||
65 | FILES+= d_init_pop_member.exp | |||
64 | FILES+= d_long_double_int.c | 66 | FILES+= d_long_double_int.c | |
65 | FILES+= d_long_double_int.exp | 67 | FILES+= d_long_double_int.exp | |
66 | FILES+= d_nested_structs.c | 68 | FILES+= d_nested_structs.c | |
67 | FILES+= d_nolimit_init.c | 69 | FILES+= d_nolimit_init.c | |
68 | FILES+= d_packed_structs.c | 70 | FILES+= d_packed_structs.c | |
69 | FILES+= d_return_type.c | 71 | FILES+= d_return_type.c | |
70 | FILES+= d_return_type.exp | 72 | FILES+= d_return_type.exp | |
71 | FILES+= d_shift_to_narrower_type.c | 73 | FILES+= d_shift_to_narrower_type.c | |
72 | FILES+= d_struct_init_nested.c | 74 | FILES+= d_struct_init_nested.c | |
73 | FILES+= d_struct_init_nested.exp | 75 | FILES+= d_struct_init_nested.exp | |
74 | FILES+= d_type_conv1.c | 76 | FILES+= d_type_conv1.c | |
75 | FILES+= d_type_conv1.exp | 77 | FILES+= d_type_conv1.exp | |
76 | FILES+= d_type_conv2.c | 78 | FILES+= d_type_conv2.c |
# 2
/*
* Between init.c 1.27 from 2015-07-28 and init.c 1.52 from 2021-01-01,
* a bug in memberpop or pop_member led to a wrong error message
* "undefined struct/union member: capital [101]" in the second and third
* named initializer.
*/
struct rgb {
unsigned red;
unsigned green;
unsigned blue;
};
struct hobbies {
unsigned dancing: 1;
unsigned running: 1;
unsigned swimming: 1;
};
struct person {
struct hobbies hobbies;
struct rgb favorite_color;
};
struct city {
struct person major;
};
struct state {
struct city capital;
};
void func(void)
{
struct state st = {
.capital.major.hobbies.dancing = 1,
/*
* Between 2015-07-28 and 2021-01-01:
* wrong "undefined struct/union member: capital [101]"
*/
/*
* As of 2020-01-01:
* wrong "warning: bit-field initializer does not fit [180]"
*/
.capital.major.favorite_color.green = 0xFF,
/*
* Between 2015-07-28 and 2021-01-01:
* wrong "undefined struct/union member: capital [101]"
*/
/*
* As of 2020-01-01:
* wrong "warning: bit-field initializer does not fit [180]"
*/
.capital.major.favorite_color.red = 0xFF
};
}
(47): undefined struct/union member: capital [101]
(47): warning: bit-field initializer does not fit [180]
(57): undefined struct/union member: capital [101]
(57): warning: bit-field initializer does not fit [180]
--- src/tests/usr.bin/xlint/lint1/t_integration.sh 2021/01/01 01:07:08 1.16
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh 2021/01/01 16:50:47 1.17
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: t_integration.sh,v 1.16 2021/01/01 01:07:08 rillig Exp $ | 1 | # $NetBSD: t_integration.sh,v 1.17 2021/01/01 16:50:47 rillig Exp $ | |
2 | # | 2 | # | |
3 | # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. | 3 | # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. | |
4 | # All rights reserved. | 4 | # All rights reserved. | |
5 | # | 5 | # | |
6 | # Redistribution and use in source and binary forms, with or without | 6 | # Redistribution and use in source and binary forms, with or without | |
7 | # modification, are permitted provided that the following conditions | 7 | # modification, are permitted provided that the following conditions | |
8 | # are met: | 8 | # are met: | |
9 | # 1. Redistributions of source code must retain the above copyright | 9 | # 1. Redistributions of source code must retain the above copyright | |
10 | # notice, this list of conditions and the following disclaimer. | 10 | # notice, this list of conditions and the following disclaimer. | |
11 | # 2. Redistributions in binary form must reproduce the above copyright | 11 | # 2. Redistributions in binary form must reproduce the above copyright | |
12 | # notice, this list of conditions and the following disclaimer in the | 12 | # notice, this list of conditions and the following disclaimer in the | |
13 | # documentation and/or other materials provided with the distribution. | 13 | # documentation and/or other materials provided with the distribution. | |
14 | # | 14 | # | |
@@ -66,26 +66,27 @@ test_case bltinoffsetof | @@ -66,26 +66,27 @@ test_case bltinoffsetof | |||
66 | test_case c99_anon_struct | 66 | test_case c99_anon_struct | |
67 | test_case c99_anon_union | 67 | test_case c99_anon_union | |
68 | test_case c99_compound_literal_comma | 68 | test_case c99_compound_literal_comma | |
69 | test_case c99_decls_after_stmt2 | 69 | test_case c99_decls_after_stmt2 | |
70 | test_case c99_flex_array_packed | 70 | test_case c99_flex_array_packed | |
71 | test_case c99_nested_struct | 71 | test_case c99_nested_struct | |
72 | test_case c99_union_cast | 72 | test_case c99_union_cast | |
73 | test_case c99_union_init4 | 73 | test_case c99_union_init4 | |
74 | test_case cast_fun_array_param | 74 | test_case cast_fun_array_param | |
75 | test_case cast_typeof | 75 | test_case cast_typeof | |
76 | test_case decl_old_style_arguments | 76 | test_case decl_old_style_arguments | |
77 | test_case fold_test | 77 | test_case fold_test | |
78 | test_case gcc_extension | 78 | test_case gcc_extension | |
79 | test_case init_pop_member | |||
79 | test_case return_type | 80 | test_case return_type | |
80 | test_case type_question_colon | 81 | test_case type_question_colon | |
81 | test_case typefun | 82 | test_case typefun | |
82 | test_case typename_as_var | 83 | test_case typename_as_var | |
83 | 84 | |||
84 | test_case c99_struct_init | 85 | test_case c99_struct_init | |
85 | test_case c99_union_init1 | 86 | test_case c99_union_init1 | |
86 | test_case c99_union_init2 | 87 | test_case c99_union_init2 | |
87 | test_case c99_union_init3 | 88 | test_case c99_union_init3 | |
88 | test_case c99_recursive_init | 89 | test_case c99_recursive_init | |
89 | test_case c9x_recursive_init | 90 | test_case c9x_recursive_init | |
90 | test_case nested_structs | 91 | test_case nested_structs | |
91 | test_case packed_structs | 92 | test_case packed_structs |
--- src/usr.bin/xlint/lint1/init.c 2021/01/01 11:41:01 1.50
+++ src/usr.bin/xlint/lint1/init.c 2021/01/01 16:50:47 1.51
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: init.c,v 1.50 2021/01/01 11:41:01 rillig Exp $ */ | 1 | /* $NetBSD: init.c,v 1.51 2021/01/01 16:50:47 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1994, 1995 Jochen Pohl | 4 | * Copyright (c) 1994, 1995 Jochen Pohl | |
5 | * All Rights Reserved. | 5 | * All Rights Reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #if HAVE_NBTOOL_CONFIG_H | 34 | #if HAVE_NBTOOL_CONFIG_H | |
35 | #include "nbtool_config.h" | 35 | #include "nbtool_config.h" | |
36 | #endif | 36 | #endif | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | #if defined(__RCSID) && !defined(lint) | 39 | #if defined(__RCSID) && !defined(lint) | |
40 | __RCSID("$NetBSD: init.c,v 1.50 2021/01/01 11:41:01 rillig Exp $"); | 40 | __RCSID("$NetBSD: init.c,v 1.51 2021/01/01 16:50:47 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <ctype.h> | 43 | #include <ctype.h> | |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> | |
45 | #include <string.h> | 45 | #include <string.h> | |
46 | 46 | |||
47 | #include "lint1.h" | 47 | #include "lint1.h" | |
48 | 48 | |||
49 | /* | 49 | /* | |
50 | * initerr is set as soon as a fatal error occurred in an initialisation. | 50 | * initerr is set as soon as a fatal error occurred in an initialisation. | |
51 | * The effect is that the rest of the initialisation is ignored (parsed | 51 | * The effect is that the rest of the initialisation is ignored (parsed | |
52 | * by yacc, expression trees built, but no initialisation takes place). | 52 | * by yacc, expression trees built, but no initialisation takes place). | |
53 | */ | 53 | */ | |
@@ -68,54 +68,58 @@ typedef struct namlist { | @@ -68,54 +68,58 @@ typedef struct namlist { | |||
68 | /* Points to a c9x named member; */ | 68 | /* Points to a c9x named member; */ | |
69 | namlist_t *namedmem = NULL; | 69 | namlist_t *namedmem = NULL; | |
70 | 70 | |||
71 | 71 | |||
72 | static int initstack_string(tnode_t *); | 72 | static int initstack_string(tnode_t *); | |
73 | 73 | |||
74 | #ifndef DEBUG | 74 | #ifndef DEBUG | |
75 | #define DPRINTF(a) | 75 | #define DPRINTF(a) | |
76 | #else | 76 | #else | |
77 | #define DPRINTF(a) printf a | 77 | #define DPRINTF(a) printf a | |
78 | #endif | 78 | #endif | |
79 | 79 | |||
80 | void | 80 | void | |
81 | push_member(sb) | 81 | push_member(sbuf_t *sb) | |
82 | sbuf_t *sb; | |||
83 | { | 82 | { | |
84 | namlist_t *nam = xcalloc(1, sizeof (namlist_t)); | 83 | namlist_t *nam = xcalloc(1, sizeof (namlist_t)); | |
85 | nam->n_name = sb->sb_name; | 84 | nam->n_name = sb->sb_name; | |
86 | DPRINTF(("%s: %s %p\n", __func__, nam->n_name, nam)); | 85 | DPRINTF(("%s: %s %p\n", __func__, nam->n_name, nam)); | |
87 | if (namedmem == NULL) { | 86 | if (namedmem == NULL) { | |
87 | /* | |||
88 | * XXX: Why is this a circular list? | |||
89 | * XXX: Why is this a doubly-linked list? | |||
90 | * A simple stack should suffice. | |||
91 | */ | |||
88 | nam->n_prev = nam->n_next = nam; | 92 | nam->n_prev = nam->n_next = nam; | |
89 | namedmem = nam; | 93 | namedmem = nam; | |
90 | } else { | 94 | } else { | |
91 | namedmem->n_prev->n_next = nam; | 95 | namedmem->n_prev->n_next = nam; | |
92 | nam->n_prev = namedmem->n_prev; | 96 | nam->n_prev = namedmem->n_prev; | |
93 | nam->n_next = namedmem; | 97 | nam->n_next = namedmem; | |
94 | namedmem->n_prev = nam; | 98 | namedmem->n_prev = nam; | |
95 | } | 99 | } | |
96 | } | 100 | } | |
97 | 101 | |||
98 | static void | 102 | static void | |
99 | pop_member(void) | 103 | pop_member(void) | |
100 | { | 104 | { | |
101 | DPRINTF(("%s: %s %p\n", __func__, namedmem->n_name, namedmem)); | 105 | DPRINTF(("%s: %s %p\n", __func__, namedmem->n_name, namedmem)); | |
102 | if (namedmem->n_next == namedmem) { | 106 | if (namedmem->n_next == namedmem) { | |
103 | free(namedmem); | 107 | free(namedmem); | |
104 | namedmem = NULL; | 108 | namedmem = NULL; | |
105 | } else { | 109 | } else { | |
106 | namlist_t *nam = namedmem; | 110 | namlist_t *nam = namedmem; | |
107 | namedmem = namedmem->n_next; | 111 | namedmem = namedmem->n_next; | |
108 | namedmem->n_next = nam->n_next; | 112 | namedmem->n_next = nam->n_next; /* FIXME: inner circle */ | |
109 | namedmem->n_prev = nam->n_prev; | 113 | namedmem->n_prev = nam->n_prev; | |
110 | free(nam); | 114 | free(nam); | |
111 | } | 115 | } | |
112 | } | 116 | } | |
113 | 117 | |||
114 | 118 | |||
115 | /* | 119 | /* | |
116 | * Initialize the initialisation stack by putting an entry for the variable | 120 | * Initialize the initialisation stack by putting an entry for the variable | |
117 | * which is to be initialized on it. | 121 | * which is to be initialized on it. | |
118 | */ | 122 | */ | |
119 | void | 123 | void | |
120 | initstack_init(void) | 124 | initstack_init(void) | |
121 | { | 125 | { |