1 /* $NetBSD: d_lint_assert.c,v 1.10 2023/08/02 18:51:25 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 (now declare_parameter). 23 */ 24 /* expect+1: warning: old-style declaration; add 'int' [1] */ 25 c(void()); 26 27 28 // As of 2023-07-15, replacing 'const' with 'unknown_type_modifier' leads to a 29 // crash. When the '}' from the 'switch' statement is processed, symbols that 30 // are already freed are still in the symbol table. To reproduce the crash, 31 // run: 32 // make -s -DDEBUG DBG="-O0 -g" 33 // MALLOC_OPTIONS='JA' MALLOC_CONF='junk:true' ./lint1 -Sy \ 34 // ../../../tests/usr.bin/xlint/lint1/d_lint_assert.c 35 static inline void f(void)36 f(void) 37 { 38 int i = 3; 39 40 for (const char *p = "";; ) { 41 switch (i) { 42 case 3:; 43 } 44 } 45 } 46