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