d_lint_assert.c revision 1.8 1 /* $NetBSD: d_lint_assert.c,v 1.8 2023/07/15 09:40:37 rillig Exp $ */
2 # 3 "d_lint_assert.c"
3
4 /*
5 * Trigger the various assertions in the lint1 code. Several of them are
6 * just hard to trigger, but not impossible.
7 */
8
9 /* lint1-extra-flags: -X 351 */
10
11 enum {
12 // Before decl.c 1.118 from 2021-01-10:
13 // lint: assertion "sym->s_scl == EXTERN || sym->s_scl == STATIC"
14 // failed in check_global_variable at decl.c:3135
15 // near d_lint_assert.c:14
16 A = +++
17 };
18 /* expect-1: error: syntax error '}' [249] */
19
20 /*
21 * Before decl.c 1.196 from 2021-07-10, lint ran into an assertion failure
22 * for 'sym->s_type != NULL' in declare_argument.
23 */
24 /* expect+1: warning: old-style declaration; add 'int' [1] */
25 c(void());
26
27
28 // As of 2023-07-15, the following code leads to a crash, due to the word
29 // 'unknown_type_modifier'. The parser then goes into error recovery mode and
30 // discards the declaration in the 'for' loop. In the end, the symbol table
31 // still contains symbols that were already freed when parsing the '}' from the
32 // 'switch' statement. To reproduce the crash, run 'make -DDEBUG DBG="-O0 -g"'
33 // and run with -Sy.
34 //
35 // static inline void
36 // f(void)
37 // {
38 // int i = 3;
39 //
40 // for (unknown_type_modifier char *p = "";; ) {
41 // switch (i) {
42 // case 3:;
43 // }
44 // }
45 // }
46