Home | History | Annotate | Line # | Download | only in lint1
msg_249.c revision 1.11
      1 /*	$NetBSD: msg_249.c,v 1.11 2022/06/16 21:24:41 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: 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: 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 /* expect+1: warning: label 'unused_label' unused in function 'access_declaration_after_syntax_error' [232] */
     70 unused_label:
     71 	1;
     72 	1;
     73 });
     74 /* expect-1: error: non-constant initializer [177] */
     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 /* expect+1: warning: label 'unused_label' unused in function 'try_to_recover' [232] */
     84 unused_label:
     85 	1;
     86 	1;
     87 });
     88 /* expect-1: error: non-constant initializer [177] */
     89