Sat Jul 10 14:45:15 2021 UTC ()
lint: rename grammar rule declmods to clrtyp_declmods

It wasn't obvious from the name 'declmods' that this rule starts a new
type declaration.

No functional change.


(rillig)
diff -r1.288 -r1.289 src/usr.bin/xlint/lint1/cgram.y

cvs diff -r1.288 -r1.289 src/usr.bin/xlint/lint1/cgram.y (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/cgram.y 2021/07/10 11:22:19 1.288
+++ src/usr.bin/xlint/lint1/cgram.y 2021/07/10 14:45:15 1.289
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: cgram.y,v 1.288 2021/07/10 11:22:19 rillig Exp $ */ 2/* $NetBSD: cgram.y,v 1.289 2021/07/10 14:45:15 rillig Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
6 * Copyright (c) 1994, 1995 Jochen Pohl 6 * Copyright (c) 1994, 1995 Jochen Pohl
7 * All Rights Reserved. 7 * All Rights Reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37#if defined(__RCSID) && !defined(lint) 37#if defined(__RCSID) && !defined(lint)
38__RCSID("$NetBSD: cgram.y,v 1.288 2021/07/10 11:22:19 rillig Exp $"); 38__RCSID("$NetBSD: cgram.y,v 1.289 2021/07/10 14:45:15 rillig Exp $");
39#endif 39#endif
40 40
41#include <limits.h> 41#include <limits.h>
42#include <stdlib.h> 42#include <stdlib.h>
43#include <string.h> 43#include <string.h>
44 44
45#include "lint1.h" 45#include "lint1.h"
46 46
47extern char *yytext; 47extern char *yytext;
48 48
49/* 49/*
50 * Contains the level of current declaration, used for symbol table entries. 50 * Contains the level of current declaration, used for symbol table entries.
51 * 0 is the top-level, > 0 is inside a function body. 51 * 0 is the top-level, > 0 is inside a function body.
@@ -435,91 +435,91 @@ function_definition: /* C99 6.9.1 */ @@ -435,91 +435,91 @@ function_definition: /* C99 6.9.1 */
435 check_func_lint_directives(); 435 check_func_lint_directives();
436 check_func_old_style_arguments(); 436 check_func_old_style_arguments();
437 begin_control_statement(CS_FUNCTION_BODY); 437 begin_control_statement(CS_FUNCTION_BODY);
438 } compound_statement { 438 } compound_statement {
439 funcend(); 439 funcend();
440 end_control_statement(CS_FUNCTION_BODY); 440 end_control_statement(CS_FUNCTION_BODY);
441 } 441 }
442 ; 442 ;
443 443
444func_decl: 444func_decl:
445 clrtyp deftyp notype_decl { 445 clrtyp deftyp notype_decl {
446 $$ = $3; 446 $$ = $3;
447 } 447 }
448 | declmods deftyp notype_decl { 448 | clrtyp_declmods deftyp notype_decl {
449 $$ = $3; 449 $$ = $3;
450 } 450 }
451 | declaration_specifiers deftyp type_decl { 451 | declaration_specifiers deftyp type_decl {
452 $$ = $3; 452 $$ = $3;
453 } 453 }
454 ; 454 ;
455 455
456arg_declaration_list_opt: /* C99 6.9.1p13 example 1 */ 456arg_declaration_list_opt: /* C99 6.9.1p13 example 1 */
457 /* empty */ 457 /* empty */
458 | arg_declaration_list 458 | arg_declaration_list
459 ; 459 ;
460 460
461arg_declaration_list: /* C99 6.9.1p13 example 1 */ 461arg_declaration_list: /* C99 6.9.1p13 example 1 */
462 arg_declaration 462 arg_declaration
463 | arg_declaration_list arg_declaration 463 | arg_declaration_list arg_declaration
464 /* XXX or better "arg_declaration error" ? */ 464 /* XXX or better "arg_declaration error" ? */
465 | error 465 | error
466 ; 466 ;
467 467
468/* 468/*
469 * "arg_declaration" is separated from "declaration" because it 469 * "arg_declaration" is separated from "declaration" because it
470 * needs other error handling. 470 * needs other error handling.
471 */ 471 */
472arg_declaration: 472arg_declaration:
473 declmods deftyp T_SEMI { 473 clrtyp_declmods deftyp T_SEMI {
474 /* empty declaration */ 474 /* empty declaration */
475 warning(2); 475 warning(2);
476 } 476 }
477 | declmods deftyp notype_init_decls T_SEMI 477 | clrtyp_declmods deftyp notype_init_decls T_SEMI
478 | declaration_specifiers deftyp T_SEMI { 478 | declaration_specifiers deftyp T_SEMI {
479 if (!dcs->d_nonempty_decl) { 479 if (!dcs->d_nonempty_decl) {
480 /* empty declaration */ 480 /* empty declaration */
481 warning(2); 481 warning(2);
482 } else { 482 } else {
483 /* '%s' declared in argument declaration list */ 483 /* '%s' declared in argument declaration list */
484 warning(3, type_name(dcs->d_type)); 484 warning(3, type_name(dcs->d_type));
485 } 485 }
486 } 486 }
487 | declaration_specifiers deftyp type_init_decls T_SEMI { 487 | declaration_specifiers deftyp type_init_decls T_SEMI {
488 if (dcs->d_nonempty_decl) { 488 if (dcs->d_nonempty_decl) {
489 /* '%s' declared in argument declaration list */ 489 /* '%s' declared in argument declaration list */
490 warning(3, type_name(dcs->d_type)); 490 warning(3, type_name(dcs->d_type));
491 } 491 }
492 } 492 }
493 | declmods error 493 | clrtyp_declmods error
494 | declaration_specifiers error 494 | declaration_specifiers error
495 ; 495 ;
496 496
497declaration: /* C99 6.7 */ 497declaration: /* C99 6.7 */
498 declaration_noerror 498 declaration_noerror
499 | error T_SEMI 499 | error T_SEMI
500 ; 500 ;
501 501
502declaration_noerror: /* see C99 6.7 'declaration' */ 502declaration_noerror: /* see C99 6.7 'declaration' */
503 declmods deftyp T_SEMI { 503 clrtyp_declmods deftyp T_SEMI {
504 if (dcs->d_scl == TYPEDEF) { 504 if (dcs->d_scl == TYPEDEF) {
505 /* typedef declares no type name */ 505 /* typedef declares no type name */
506 warning(72); 506 warning(72);
507 } else { 507 } else {
508 /* empty declaration */ 508 /* empty declaration */
509 warning(2); 509 warning(2);
510 } 510 }
511 } 511 }
512 | declmods deftyp notype_init_decls T_SEMI 512 | clrtyp_declmods deftyp notype_init_decls T_SEMI
513 | declaration_specifiers deftyp T_SEMI { 513 | declaration_specifiers deftyp T_SEMI {
514 if (dcs->d_scl == TYPEDEF) { 514 if (dcs->d_scl == TYPEDEF) {
515 /* typedef declares no type name */ 515 /* typedef declares no type name */
516 warning(72); 516 warning(72);
517 } else if (!dcs->d_nonempty_decl) { 517 } else if (!dcs->d_nonempty_decl) {
518 /* empty declaration */ 518 /* empty declaration */
519 warning(2); 519 warning(2);
520 } 520 }
521 } 521 }
522 | declaration_specifiers deftyp type_init_decls T_SEMI 522 | declaration_specifiers deftyp type_init_decls T_SEMI
523 ; 523 ;
524 524
525clrtyp: 525clrtyp:
@@ -528,39 +528,39 @@ clrtyp: @@ -528,39 +528,39 @@ clrtyp:
528 } 528 }
529 ; 529 ;
530 530
531deftyp: 531deftyp:
532 /* empty */ { 532 /* empty */ {
533 deftyp(); 533 deftyp();
534 } 534 }
535 ; 535 ;
536 536
537declaration_specifiers: /* C99 6.7 */ 537declaration_specifiers: /* C99 6.7 */
538 clrtyp_typespec { 538 clrtyp_typespec {
539 add_type($1); 539 add_type($1);
540 } 540 }
541 | declmods typespec { 541 | clrtyp_declmods typespec {
542 add_type($2); 542 add_type($2);
543 } 543 }
544 | type_attribute declaration_specifiers 544 | type_attribute declaration_specifiers
545 | declaration_specifiers declmod 545 | declaration_specifiers declmod
546 | declaration_specifiers notype_typespec { 546 | declaration_specifiers notype_typespec {
547 add_type($2); 547 add_type($2);
548 } 548 }
549 ; 549 ;
550 550
551declmods: 551clrtyp_declmods:
552 clrtyp qualifier_or_storage_class 552 clrtyp qualifier_or_storage_class
553 | declmods declmod 553 | clrtyp_declmods declmod
554 ; 554 ;
555 555
556declmod: 556declmod:
557 qualifier_or_storage_class 557 qualifier_or_storage_class
558 | type_attribute 558 | type_attribute
559 ; 559 ;
560 560
561qualifier_or_storage_class: 561qualifier_or_storage_class:
562 T_QUAL { 562 T_QUAL {
563 add_qualifier($1); 563 add_qualifier($1);
564 } 564 }
565 | T_SCLASS { 565 | T_SCLASS {
566 add_storage_class($1); 566 add_storage_class($1);
@@ -1150,39 +1150,39 @@ vararg_parameter_type_list: @@ -1150,39 +1150,39 @@ vararg_parameter_type_list:
1150 $$ = NULL; 1150 $$ = NULL;
1151 } 1151 }
1152 ; 1152 ;
1153 1153
1154parameter_type_list: 1154parameter_type_list:
1155 parameter_declaration 1155 parameter_declaration
1156 | parameter_type_list T_COMMA parameter_declaration { 1156 | parameter_type_list T_COMMA parameter_declaration {
1157 $$ = lnklst($1, $3); 1157 $$ = lnklst($1, $3);
1158 } 1158 }
1159 ; 1159 ;
1160 1160
1161/* XXX: C99 6.7.5 defines the same name, but it looks completely different. */ 1161/* XXX: C99 6.7.5 defines the same name, but it looks completely different. */
1162parameter_declaration: 1162parameter_declaration:
1163 declmods deftyp { 1163 clrtyp_declmods deftyp {
1164 $$ = declare_argument(abstract_name(), false); 1164 $$ = declare_argument(abstract_name(), false);
1165 } 1165 }
1166 | declaration_specifiers deftyp { 1166 | declaration_specifiers deftyp {
1167 $$ = declare_argument(abstract_name(), false); 1167 $$ = declare_argument(abstract_name(), false);
1168 } 1168 }
1169 | declmods deftyp notype_param_decl { 1169 | clrtyp_declmods deftyp notype_param_decl {
1170 $$ = declare_argument($3, false); 1170 $$ = declare_argument($3, false);
1171 } 1171 }
1172 | declaration_specifiers deftyp type_param_decl { 1172 | declaration_specifiers deftyp type_param_decl {
1173 $$ = declare_argument($3, false); 1173 $$ = declare_argument($3, false);
1174 } 1174 }
1175 | declmods deftyp abstract_declarator { 1175 | clrtyp_declmods deftyp abstract_declarator {
1176 $$ = declare_argument($3, false); 1176 $$ = declare_argument($3, false);
1177 } 1177 }
1178 | declaration_specifiers deftyp abstract_declarator { 1178 | declaration_specifiers deftyp abstract_declarator {
1179 $$ = declare_argument($3, false); 1179 $$ = declare_argument($3, false);
1180 } 1180 }
1181 ; 1181 ;
1182 1182
1183asm_or_symbolrename_opt: /* expect only one */ 1183asm_or_symbolrename_opt: /* expect only one */
1184 /* empty */ { 1184 /* empty */ {
1185 $$ = NULL; 1185 $$ = NULL;
1186 } 1186 }
1187 | T_ASM T_LPAREN T_STRING T_RPAREN { 1187 | T_ASM T_LPAREN T_STRING T_RPAREN {
1188 freeyyv(&$3, T_STRING); 1188 freeyyv(&$3, T_STRING);