1 /* $NetBSD: msg_249.c,v 1.16 2024/11/13 04:32:49 rillig Exp $ */ 2 # 3 "msg_249.c" 3 4 // Test for message: syntax error '%s' [249] 5 6 /* lint1-extra-flags: -X 351 */ 7 8 /* 9 * Cover the grammar rule 'top_level_declaration: error T_SEMI'. 10 */ 11 /* expect+1: error: syntax error '"' [249] */ 12 "syntax error in top_level_declaration"; 13 14 /* XXX: This is necessary to recover the yacc parser. */ 15 int recover_from_semi; 16 17 /* 18 * Cover the grammar rule 'top_level_declaration: error T_RBRACE'. 19 */ 20 /* expect+1: error: syntax error '"' [249] */ 21 "syntax error in top_level_declaration"} 22 23 /* XXX: This is necessary to recover the yacc parser. */ 24 int recover_from_rbrace; 25 26 /* 27 * Before func.c 1.110 from 2021-06-19, lint ran into this: 28 * assertion "cstmt->c_kind == kind" failed in end_control_statement 29 */ 30 void 31 function(void) 32 { 33 if (0) 34 /* expect+1: warning: 'empty' statement not reached [193] */ 35 ; 36 /* expect+1: error: syntax error ')' [249] */ 37 ); 38 } 39 40 /* XXX: It is unexpected that this error is not detected. */ 41 "This syntax error is not detected."; 42 43 /* XXX: This is necessary to recover the yacc parser. */ 44 double recover_from_rparen; 45 46 /* Ensure that the declaration after the syntax error is processed. */ 47 double * 48 access_declaration_after_syntax_error(void) 49 { 50 return &recover_from_rparen; 51 } 52 53 struct cover_member_declaration { 54 /* cover 'noclass_declmods ... notype_member_decls' */ 55 const noclass_declmods; 56 57 /* cover 'noclass_declspecs ...' */ 58 const int noclass_declspecs; 59 60 /* cover 'add_type_qualifier_list end_type' */ 61 /* expect+1: error: syntax error 'member without type' [249] */ 62 const; 63 }; 64 65 /* 66 * At this point, lint assumes that the following code is still in the 67 * function 'access_declaration_after_syntax_error'. 68 */ 69 70 int gcc_statement_expression_1 = ({ 71 unused_label: 72 1; 73 1; 74 /* expect+2: error: syntax error 'labels are only valid inside a function' [249] */ 75 /* expect+1: error: non-constant initializer [177] */ 76 }); 77 78 /* Even another function definition does not help. */ 79 void 80 try_to_recover(void) 81 { 82 } 83 84 int gcc_statement_expression_2 = ({ 85 unused_label: 86 1; 87 1; 88 /* expect+2: error: syntax error 'labels are only valid inside a function' [249] */ 89 /* expect+1: error: non-constant initializer [177] */ 90 }); 91