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