[BACK]Return to cgram.y CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / xlint / lint1

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/usr.bin/xlint/lint1/cgram.y between version 1.305 and 1.306

version 1.305, 2021/07/10 22:46:02 version 1.306, 2021/07/11 15:07:39
Line 124  anonymize(sym_t *s)
Line 124  anonymize(sym_t *s)
   
 %}  %}
   
 %expect 131  %expect 178
   
 %union {  %union {
         val_t   *y_val;          val_t   *y_val;
Line 282  anonymize(sym_t *s)
Line 282  anonymize(sym_t *s)
 %type   <y_sym>         notype_decl  %type   <y_sym>         notype_decl
 %type   <y_sym>         type_decl  %type   <y_sym>         type_decl
 %type   <y_type>        type_specifier  %type   <y_type>        type_specifier
   %type   <y_type>        begin_type_typespec
 %type   <y_type>        notype_type_specifier  %type   <y_type>        notype_type_specifier
 %type   <y_type>        struct_or_union_specifier  %type   <y_type>        struct_or_union_specifier
 %type   <y_type>        enum_specifier  %type   <y_type>        enum_specifier
 %type   <y_tspec>       struct_or_union  %type   <y_tspec>       struct_or_union
 %type   <y_sym>         identifier_sym_opt  %type   <y_sym>         braced_struct_declaration_list
 %type   <y_sym>         identifier_sym  %type   <y_sym>         identifier_sym
 %type   <y_name>        identifier  %type   <y_name>        identifier
 %type   <y_sym>         struct_declaration_list_semi  %type   <y_sym>         struct_declaration_list_with_rbrace
 %type   <y_sym>         struct_declaration_list  %type   <y_sym>         struct_declaration_list
 %type   <y_sym>         struct_declaration  %type   <y_sym>         struct_declaration
 %type   <y_sym>         notype_member_decls  %type   <y_sym>         notype_member_decls
Line 298  anonymize(sym_t *s)
Line 299  anonymize(sym_t *s)
 %type   <y_sym>         type_member_decl  %type   <y_sym>         type_member_decl
 %type   <y_tnode>       constant_expr  %type   <y_tnode>       constant_expr
 %type   <y_tnode>       array_size  %type   <y_tnode>       array_size
   %type   <y_sym>         enum_declaration
   %type   <y_sym>         enums_with_opt_comma
 %type   <y_sym>         enumerator_list  %type   <y_sym>         enumerator_list
 %type   <y_sym>         enumerator  %type   <y_sym>         enumerator
 %type   <y_sym>         notype_direct_decl  %type   <y_sym>         notype_direct_decl
Line 316  anonymize(sym_t *s)
Line 319  anonymize(sym_t *s)
 %type   <y_sym>         identifier_list  %type   <y_sym>         identifier_list
 %type   <y_sym>         abstract_declarator  %type   <y_sym>         abstract_declarator
 %type   <y_sym>         direct_abstract_declarator  %type   <y_sym>         direct_abstract_declarator
 %type   <y_sym>         direct_abstract_declarator_postfix  
 %type   <y_sym>         vararg_parameter_type_list  %type   <y_sym>         vararg_parameter_type_list
 %type   <y_sym>         parameter_type_list  %type   <y_sym>         parameter_type_list
 %type   <y_sym>         parameter_declaration  %type   <y_sym>         parameter_declaration
Line 330  anonymize(sym_t *s)
Line 332  anonymize(sym_t *s)
 %type   <y_op>          point_or_arrow  %type   <y_op>          point_or_arrow
 %type   <y_type>        type_name  %type   <y_type>        type_name
 %type   <y_sym>         abstract_declaration  %type   <y_sym>         abstract_declaration
   %type   <y_tnode>       do_while_expr
 %type   <y_tnode>       expr_opt  %type   <y_tnode>       expr_opt
 %type   <y_string>      string  %type   <y_string>      string
 %type   <y_string>      string2  %type   <y_string>      string2
Line 400  top_level_declaration:  /* C99 6.9 calls
Line 403  top_level_declaration:  /* C99 6.9 calls
                         warning(1);                          warning(1);
                 }                  }
           }            }
         | declaration_noerror          | begin_type_declmods end_type T_SEMI {
                   if (dcs->d_scl == TYPEDEF) {
                           /* typedef declares no type name */
                           warning(72);
                   } else {
                           /* empty declaration */
                           warning(2);
                   }
             }
           | begin_type_declmods end_type notype_init_decls T_SEMI
           | begin_type_declaration_specifiers end_type T_SEMI {
                   if (dcs->d_scl == TYPEDEF) {
                           /* typedef declares no type name */
                           warning(72);
                   } else if (!dcs->d_nonempty_decl) {
                           /* empty declaration */
                           warning(2);
                   }
             }
           | begin_type_declaration_specifiers end_type type_init_decls T_SEMI
         | error T_SEMI {          | error T_SEMI {
                 global_clean_up();                  global_clean_up();
           }            }
Line 442  func_decl:
Line 464  func_decl:
           begin_type end_type notype_decl {            begin_type end_type notype_decl {
                 $$ = $3;                  $$ = $3;
           }            }
         | begin_type declmods end_type notype_decl {          | begin_type_declmods end_type notype_decl {
                 $$ = $4;                  $$ = $3;
           }            }
         | begin_type declaration_specifiers end_type type_decl {          | begin_type_declaration_specifiers end_type type_decl {
                 $$ = $4;                  $$ = $3;
           }            }
         ;          ;
   
Line 467  arg_declaration_list:  /* C99 6.9.1p13 e
Line 489  arg_declaration_list:  /* C99 6.9.1p13 e
  * needs other error handling.   * needs other error handling.
  */   */
 arg_declaration:  arg_declaration:
           begin_type declmods end_type T_SEMI {            begin_type_declmods end_type T_SEMI {
                 /* empty declaration */                  /* empty declaration */
                 warning(2);                  warning(2);
           }            }
         | begin_type declmods end_type notype_init_decls T_SEMI          | begin_type_declmods end_type notype_init_decls T_SEMI
         | begin_type declaration_specifiers end_type T_SEMI {          | begin_type_declaration_specifiers end_type T_SEMI {
                 if (!dcs->d_nonempty_decl) {                  if (!dcs->d_nonempty_decl) {
                         /* empty declaration */                          /* empty declaration */
                         warning(2);                          warning(2);
Line 481  arg_declaration:
Line 503  arg_declaration:
                         warning(3, type_name(dcs->d_type));                          warning(3, type_name(dcs->d_type));
                 }                  }
           }            }
         | begin_type declaration_specifiers end_type type_init_decls T_SEMI {          | begin_type_declaration_specifiers end_type type_init_decls T_SEMI {
                 if (dcs->d_nonempty_decl) {                  if (dcs->d_nonempty_decl) {
                         /* '%s' declared in argument declaration list */                          /* '%s' declared in argument declaration list */
                         warning(3, type_name(dcs->d_type));                          warning(3, type_name(dcs->d_type));
                 }                  }
           }            }
         | begin_type declmods error          | begin_type_declmods error
         | begin_type declaration_specifiers error          | begin_type_declaration_specifiers error
         ;          ;
   
 declaration:                    /* C99 6.7 */  declaration:                    /* C99 6.7 */
           declaration_noerror            begin_type_declmods end_type T_SEMI {
         | error T_SEMI  
         ;  
   
 declaration_noerror:            /* see C99 6.7 'declaration' */  
           begin_type declmods end_type T_SEMI {  
                 if (dcs->d_scl == TYPEDEF) {                  if (dcs->d_scl == TYPEDEF) {
                         /* typedef declares no type name */                          /* typedef declares no type name */
                         warning(72);                          warning(72);
Line 506  declaration_noerror:  /* see C99 6.7 'de
Line 523  declaration_noerror:  /* see C99 6.7 'de
                         warning(2);                          warning(2);
                 }                  }
           }            }
         | begin_type declmods end_type notype_init_decls T_SEMI          | begin_type_declmods end_type notype_init_decls T_SEMI
         | begin_type declaration_specifiers end_type T_SEMI {          | begin_type_declaration_specifiers end_type T_SEMI {
                 if (dcs->d_scl == TYPEDEF) {                  if (dcs->d_scl == TYPEDEF) {
                         /* typedef declares no type name */                          /* typedef declares no type name */
                         warning(72);                          warning(72);
Line 516  declaration_noerror:  /* see C99 6.7 'de
Line 533  declaration_noerror:  /* see C99 6.7 'de
                         warning(2);                          warning(2);
                 }                  }
           }            }
         | begin_type declaration_specifiers end_type type_init_decls T_SEMI          | begin_type_declaration_specifiers end_type type_init_decls T_SEMI
           | error T_SEMI
         ;          ;
   
 begin_type:  begin_type:
Line 531  end_type:
Line 549  end_type:
           }            }
         ;          ;
   
 declaration_specifiers:         /* C99 6.7 */  begin_type_declaration_specifiers:      /* see C99 6.7 */
           add_type_specifier            begin_type_typespec {
         | declmods add_type_specifier                  add_type($1);
         | type_attribute declaration_specifiers            }
         | declaration_specifiers add_storage_class          | begin_type_declmods type_specifier {
         | declaration_specifiers add_notype_type_specifier                  add_type($2);
         | declaration_specifiers add_type_qualifier            }
         | declaration_specifiers type_attribute          | type_attribute begin_type_declaration_specifiers
         ;          | begin_type_declaration_specifiers declmod
           | begin_type_declaration_specifiers notype_type_specifier {
 declmods:                  add_type($2);
           add_storage_class            }
         | add_type_qualifier  
         | declmods add_storage_class  
         | declmods add_type_qualifier  
         | declmods type_attribute  
         ;          ;
   
 add_storage_class:  begin_type_declmods:
           T_SCLASS {            begin_type T_QUAL {
                 add_storage_class($1);                  add_qualifier($2);
           }            }
           | begin_type T_SCLASS {
                   add_storage_class($2);
             }
           | begin_type_declmods declmod
         ;          ;
   
 add_type_specifier:  declmod:
           type_specifier {            T_QUAL {
                 add_type($1);                  add_qualifier($1);
             }
           | T_SCLASS {
                   add_storage_class($1);
           }            }
           | type_attribute_list
         ;          ;
   
 type_attribute_list_opt:  begin_type_typespec:
           /* empty */            begin_type notype_type_specifier {
         | type_attribute_list                  $$ = $2;
             }
           | T_TYPENAME begin_type {
                   $$ = getsym($1)->s_type;
             }
         ;          ;
   
 type_attribute_list:  type_attribute_list:
Line 577  type_attribute_opt:
Line 603  type_attribute_opt:
         ;          ;
   
 type_attribute:                 /* See C11 6.7 declaration-specifiers */  type_attribute:                 /* See C11 6.7 declaration-specifiers */
           gcc_attribute            T_ATTRIBUTE T_LPAREN T_LPAREN {
               attron = true;
             } gcc_attribute_spec_list {
               attron = false;
             } T_RPAREN T_RPAREN
         | T_ALIGNAS T_LPAREN align_as T_RPAREN          | T_ALIGNAS T_LPAREN align_as T_RPAREN
         | T_PACKED {          | T_PACKED {
                 addpacked();                  addpacked();
Line 592  type_specifier:   /* C99 6.7.2 */
Line 622  type_specifier:   /* C99 6.7.2 */
           }            }
         ;          ;
   
 add_notype_type_specifier:  
           notype_type_specifier {  
                 add_type($1);  
           }  
         ;  
   
 /* Like type_specifier, but without typedef-name. */  
 notype_type_specifier:  notype_type_specifier:
           T_TYPE {            T_TYPE {
                 $$ = gettyp($1);                  $$ = gettyp($1);
Line 627  struct_or_union_specifier: /* C99 6.7.2.
Line 650  struct_or_union_specifier: /* C99 6.7.2.
                  */                   */
                 $$ = mktag($2, $1, false, yychar == T_SEMI);                  $$ = mktag($2, $1, false, yychar == T_SEMI);
           }            }
         | struct_or_union identifier_sym_opt {          | struct_or_union identifier_sym {
                 dcs->d_tagtyp = mktag($2, $1, true, false);                  dcs->d_tagtyp = mktag($2, $1, true, false);
           } T_LBRACE {            } braced_struct_declaration_list {
                 symtyp = FVFT;                  $$ = complete_tag_struct_or_union(dcs->d_tagtyp, $4);
           } struct_declaration_list_semi T_RBRACE {            }
                 $$ = complete_tag_struct_or_union(dcs->d_tagtyp, $6);          | struct_or_union {
                   dcs->d_tagtyp = mktag(NULL, $1, true, false);
             } braced_struct_declaration_list {
                   $$ = complete_tag_struct_or_union(dcs->d_tagtyp, $3);
           }            }
         | struct_or_union error {          | struct_or_union error {
                 symtyp = FVFT;                  symtyp = FVFT;
Line 641  struct_or_union_specifier: /* C99 6.7.2.
Line 667  struct_or_union_specifier: /* C99 6.7.2.
         ;          ;
   
 struct_or_union:                /* C99 6.7.2.1 */  struct_or_union:                /* C99 6.7.2.1 */
           T_STRUCT_OR_UNION {            struct_or_union type_attribute
           | T_STRUCT_OR_UNION {
                 symtyp = FTAG;                  symtyp = FTAG;
                 begin_declaration_level($1 == STRUCT ? MOS : MOU);                  begin_declaration_level($1 == STRUCT ? MOS : MOU);
                 dcs->d_offset = 0;                  dcs->d_offset = 0;
                 dcs->d_sou_align_in_bits = CHAR_SIZE;                  dcs->d_sou_align_in_bits = CHAR_SIZE;
           } type_attribute_list_opt                  $$ = $1;
             }
         ;          ;
   
 struct_declaration_list_semi:  braced_struct_declaration_list:
           /* empty */ {            struct_declaration_lbrace struct_declaration_list_with_rbrace {
                 $$ = NULL;                  $$ = $2;
           }            }
         | struct_declaration_list T_SEMI          ;
         | struct_declaration_list {  
   struct_declaration_lbrace:
             T_LBRACE {
                   symtyp = FVFT;
             }
           ;
   
   struct_declaration_list_with_rbrace:
             struct_declaration_list T_SEMI T_RBRACE
           | struct_declaration_list T_RBRACE {
                 if (sflag) {                  if (sflag) {
                         /* syntax req. ';' after last struct/union member */                          /* syntax req. ';' after last struct/union member */
                         error(66);                          error(66);
Line 664  struct_declaration_list_semi:
Line 701  struct_declaration_list_semi:
                 }                  }
                 $$ = $1;                  $$ = $1;
           }            }
           | T_RBRACE {
                   $$ = NULL;
             }
         ;          ;
   
 struct_declaration_list:  struct_declaration_list:
Line 674  struct_declaration_list:
Line 714  struct_declaration_list:
         ;          ;
   
 struct_declaration:  struct_declaration:
           begin_type add_type_qualifier_list end_type {            begin_type_noclass_declmods end_type {
                 /* too late, i know, but getsym() compensates it */                  /* too late, i know, but getsym() compensates it */
                 symtyp = FMEMBER;                  symtyp = FMEMBER;
           } notype_member_decls type_attribute_opt {            } notype_member_decls type_attribute_opt {
                 symtyp = FVFT;                  symtyp = FVFT;
                 $$ = $5;                  $$ = $4;
           }            }
         | begin_type noclass_declspecs end_type {          | begin_type_noclass_declspecs end_type {
                 symtyp = FMEMBER;                  symtyp = FMEMBER;
           } type_member_decls type_attribute_opt {            } type_member_decls type_attribute_opt {
                 symtyp = FVFT;                  symtyp = FVFT;
                 $$ = $5;                  $$ = $4;
           }            }
         | begin_type add_type_qualifier_list end_type type_attribute_opt {          | begin_type_noclass_declmods end_type type_attribute_opt {
                 /* syntax error '%s' */                  /* syntax error '%s' */
                 error(249, "member without type");                  error(249, "member without type");
                 $$ = NULL;                  $$ = NULL;
           }            }
         | begin_type noclass_declspecs end_type type_attribute_opt {          | begin_type_noclass_declspecs end_type type_attribute_opt {
                 symtyp = FVFT;                  symtyp = FVFT;
                 if (!Sflag)                  if (!Sflag)
                         /* anonymous struct/union members is a C9X feature */                          /* anonymous struct/union members is a C9X feature */
Line 713  struct_declaration:
Line 753  struct_declaration:
           }            }
         ;          ;
   
 noclass_declspecs:  begin_type_noclass_declspecs:
           noclass_declspecs_postfix            begin_type_typespec {
         | type_attribute noclass_declspecs                  add_type($1);
         ;            }
           | type_attribute begin_type_noclass_declspecs
 noclass_declspecs_postfix:          | begin_type_noclass_declmods type_specifier {
           add_type_specifier                  add_type($2);
         | add_type_qualifier_list add_type_specifier            }
         | noclass_declspecs_postfix add_type_qualifier          | begin_type_noclass_declspecs T_QUAL {
         | noclass_declspecs_postfix add_notype_type_specifier                  add_qualifier($2);
         | noclass_declspecs_postfix type_attribute            }
         ;          | begin_type_noclass_declspecs notype_type_specifier {
                   add_type($2);
 add_type_qualifier_list:            }
           add_type_qualifier          | begin_type_noclass_declspecs type_attribute
         | add_type_qualifier_list add_type_qualifier  
         ;          ;
   
 add_type_qualifier:  begin_type_noclass_declmods:
           T_QUAL {            begin_type T_QUAL {
                 add_qualifier($1);                  add_qualifier($2);
             }
           | begin_type_noclass_declmods T_QUAL {
                   add_qualifier($2);
           }            }
         ;          ;
   
Line 787  enum_specifier:  /* C99 6.7.2.2 */
Line 829  enum_specifier:  /* C99 6.7.2.2 */
           enum identifier_sym {            enum identifier_sym {
                 $$ = mktag($2, ENUM, false, false);                  $$ = mktag($2, ENUM, false, false);
           }            }
         | enum identifier_sym_opt {          | enum identifier_sym {
                 dcs->d_tagtyp = mktag($2, ENUM, true, false);                  dcs->d_tagtyp = mktag($2, ENUM, true, false);
           } T_LBRACE {            } enum_declaration {
                 symtyp = FVFT;                  $$ = complete_tag_enum(dcs->d_tagtyp, $4);
                 enumval = 0;            }
           } enumerator_list enumerator_list_comma_opt T_RBRACE {          | enum {
                 $$ = complete_tag_enum(dcs->d_tagtyp, $6);                  dcs->d_tagtyp = mktag(NULL, ENUM, true, false);
             } enum_declaration {
                   $$ = complete_tag_enum(dcs->d_tagtyp, $3);
           }            }
         | enum error {          | enum error {
                 symtyp = FVFT;                  symtyp = FVFT;
Line 808  enum:
Line 852  enum:
           }            }
         ;          ;
   
 enumerator_list:                /* C99 6.7.2.2 */  enum_declaration:
           enumerator            enum_decl_lbrace enums_with_opt_comma T_RBRACE {
         | enumerator_list T_COMMA enumerator {                  $$ = $2;
                 $$ = lnklst($1, $3);  
           }            }
         | error {          ;
                 $$ = NULL;  
   enum_decl_lbrace:
             T_LBRACE {
                   symtyp = FVFT;
                   enumval = 0;
           }            }
         ;          ;
   
 enumerator_list_comma_opt:  enums_with_opt_comma:
           /* empty */            enumerator_list
         | T_COMMA {          | enumerator_list T_COMMA {
                 if (sflag) {                  if (sflag) {
                         /* trailing ',' prohibited in enum declaration */                          /* trailing ',' prohibited in enum declaration */
                         error(54);                          error(54);
Line 828  enumerator_list_comma_opt:
Line 875  enumerator_list_comma_opt:
                         /* trailing ',' prohibited in enum declaration */                          /* trailing ',' prohibited in enum declaration */
                         c99ism(54);                          c99ism(54);
                 }                  }
                   $$ = $1;
             }
           ;
   
   enumerator_list:
             enumerator
           | enumerator_list T_COMMA enumerator {
                   $$ = lnklst($1, $3);
             }
           | error {
                   $$ = NULL;
           }            }
         ;          ;
   
Line 885  type_init_decl:
Line 943  type_init_decl:
         ;          ;
   
 notype_decl:  notype_decl:
         /* TODO: removing type_attribute_list_opt here removes another 18 conflicts */            notype_direct_decl
           type_attribute_list_opt notype_direct_decl {          | pointer notype_direct_decl {
                 $$ = $2;                  $$ = add_pointer($2, $1);
           }  
         | pointer type_attribute_list_opt notype_direct_decl {  
                 $$ = add_pointer($3, $1);  
           }            }
         ;          ;
   
 type_decl:  type_decl:
         /* TODO: removing type_attribute_list_opt here removes another 16 conflicts */            type_direct_decl
           type_attribute_list_opt type_direct_decl {          | pointer type_direct_decl {
                 $$ = $2;                  $$ = add_pointer($2, $1);
           }  
         | pointer type_attribute_list_opt type_direct_decl {  
                 $$ = add_pointer($3, $1);  
           }            }
         ;          ;
   
Line 911  notype_direct_decl:
Line 963  notype_direct_decl:
         | T_LPAREN type_decl T_RPAREN {          | T_LPAREN type_decl T_RPAREN {
                 $$ = $2;                  $$ = $2;
           }            }
           | type_attribute notype_direct_decl {
                   $$ = $2;
             }
         | notype_direct_decl T_LBRACK T_RBRACK {          | notype_direct_decl T_LBRACK T_RBRACK {
                 $$ = add_array($1, false, 0);                  $$ = add_array($1, false, 0);
           }            }
Line 922  notype_direct_decl:
Line 977  notype_direct_decl:
                 end_declaration_level();                  end_declaration_level();
                 block_level--;                  block_level--;
           }            }
         | notype_direct_decl type_attribute          | notype_direct_decl type_attribute_list
         ;          ;
   
 type_direct_decl:  type_direct_decl:
Line 932  type_direct_decl:
Line 987  type_direct_decl:
         | T_LPAREN type_decl T_RPAREN {          | T_LPAREN type_decl T_RPAREN {
                 $$ = $2;                  $$ = $2;
           }            }
           | type_attribute type_direct_decl {
                   $$ = $2;
             }
         | type_direct_decl T_LBRACK T_RBRACK {          | type_direct_decl T_LBRACK T_RBRACK {
                 $$ = add_array($1, false, 0);                  $$ = add_array($1, false, 0);
           }            }
Line 960  type_param_decl:
Line 1018  type_param_decl:
           }            }
         ;          ;
   
 notype_param_decl:  array_size:
           direct_notype_param_decl            type_qualifier_list_opt T_SCLASS constant_expr {
         | pointer direct_notype_param_decl {                  /* C11 6.7.6.3p7 */
                 $$ = add_pointer($2, $1);                  if ($2 != STATIC)
                           yyerror("Bad attribute");
                   /* static array size is a C11 extension */
                   c11ism(343);
                   $$ = $3;
           }            }
           | constant_expr
         ;          ;
   
 direct_param_decl:  direct_param_decl:
           identifier type_attribute_list_opt {            identifier type_attribute_list {
                   $$ = declarator_name(getsym($1));
             }
           | identifier {
                 $$ = declarator_name(getsym($1));                  $$ = declarator_name(getsym($1));
           }            }
         | T_LPAREN notype_param_decl T_RPAREN {          | T_LPAREN notype_param_decl T_RPAREN {
Line 987  direct_param_decl:
Line 1053  direct_param_decl:
           }            }
         ;          ;
   
   notype_param_decl:
             direct_notype_param_decl
           | pointer direct_notype_param_decl {
                   $$ = add_pointer($2, $1);
             }
           ;
   
 direct_notype_param_decl:  direct_notype_param_decl:
           identifier /* XXX: missing type_attribute_list_opt? */ {            identifier {
                 $$ = declarator_name(getsym($1));                  $$ = declarator_name(getsym($1));
           }            }
         | T_LPAREN notype_param_decl T_RPAREN {          | T_LPAREN notype_param_decl T_RPAREN {
Line 1128  parameter_type_list:
Line 1201  parameter_type_list:
   
 /* XXX: C99 6.7.5 defines the same name, but it looks completely different. */  /* XXX: C99 6.7.5 defines the same name, but it looks completely different. */
 parameter_declaration:  parameter_declaration:
           begin_type declmods end_type {            begin_type_declmods end_type {
                 $$ = declare_argument(abstract_name(), false);                  $$ = declare_argument(abstract_name(), false);
           }            }
         | begin_type declaration_specifiers end_type {          | begin_type_declaration_specifiers end_type {
                 $$ = declare_argument(abstract_name(), false);                  $$ = declare_argument(abstract_name(), false);
           }            }
         | begin_type declmods end_type notype_param_decl {          | begin_type_declmods end_type notype_param_decl {
                 $$ = declare_argument($4, false);                  $$ = declare_argument($3, false);
           }            }
         | begin_type declaration_specifiers end_type type_param_decl {          /*
                 $$ = declare_argument($4, false);           * type_param_decl is needed because of following conflict:
            * "typedef int a; f(int (a));" could be parsed as
            * "function with argument a of type int", or
            * "function with an abstract argument of type function".
            * This grammar realizes the second case.
            */
           | begin_type_declaration_specifiers end_type type_param_decl {
                   $$ = declare_argument($3, false);
           }            }
         | begin_type declmods end_type abstract_declarator {          | begin_type_declmods end_type abstract_declarator {
                 $$ = declare_argument($4, false);                  $$ = declare_argument($3, false);
           }            }
         | begin_type declaration_specifiers end_type abstract_declarator {          | begin_type_declaration_specifiers end_type abstract_declarator {
                 $$ = declare_argument($4, false);                  $$ = declare_argument($3, false);
           }            }
         ;          ;
   
Line 1246  type_name:   /* C99 6.7.6 */
Line 1326  type_name:   /* C99 6.7.6 */
         ;          ;
   
 abstract_declaration:  abstract_declaration:
           begin_type add_type_qualifier_list end_type {            begin_type_noclass_declmods end_type {
                 $$ = declare_1_abstract(abstract_name());                  $$ = declare_1_abstract(abstract_name());
           }            }
         | begin_type noclass_declspecs end_type {          | begin_type_noclass_declspecs end_type {
                 $$ = declare_1_abstract(abstract_name());                  $$ = declare_1_abstract(abstract_name());
           }            }
         | begin_type add_type_qualifier_list end_type abstract_declarator {          | begin_type_noclass_declmods end_type abstract_declarator {
                 $$ = declare_1_abstract($4);                  $$ = declare_1_abstract($3);
           }            }
         | begin_type noclass_declspecs end_type abstract_declarator {          | begin_type_noclass_declspecs end_type abstract_declarator {
                 $$ = declare_1_abstract($4);                  $$ = declare_1_abstract($3);
           }            }
         ;          ;
   
Line 1274  abstract_declarator:  /* C99 6.7.6 */
Line 1354  abstract_declarator:  /* C99 6.7.6 */
         ;          ;
   
 direct_abstract_declarator:             /* C99 6.7.6 */  direct_abstract_declarator:             /* C99 6.7.6 */
           direct_abstract_declarator_postfix  
         | type_attribute direct_abstract_declarator_postfix {  
                 $$ = $2;  
           }  
         ;  
   
 direct_abstract_declarator_postfix:     /* C99 6.7.6 */  
           T_LPAREN abstract_declarator T_RPAREN {            T_LPAREN abstract_declarator T_RPAREN {
                 $$ = $2;                  $$ = $2;
           }            }
Line 1290  direct_abstract_declarator_postfix: /* C
Line 1363  direct_abstract_declarator_postfix: /* C
         | T_LBRACK array_size T_RBRACK {          | T_LBRACK array_size T_RBRACK {
                 $$ = add_array(abstract_name(), true, to_int_constant($2, false));                  $$ = add_array(abstract_name(), true, to_int_constant($2, false));
           }            }
         | direct_abstract_declarator_postfix T_LBRACK T_RBRACK {          | type_attribute direct_abstract_declarator {
                   $$ = $2;
             }
           | direct_abstract_declarator T_LBRACK T_RBRACK {
                 $$ = add_array($1, false, 0);                  $$ = add_array($1, false, 0);
           }            }
         | direct_abstract_declarator_postfix          | direct_abstract_declarator T_LBRACK T_ASTERISK T_RBRACK { /* C99 */
             T_LBRACK T_ASTERISK T_RBRACK {      /* C99 */  
                 $$ = add_array($1, false, 0);                  $$ = add_array($1, false, 0);
           }            }
         | direct_abstract_declarator_postfix T_LBRACK array_size T_RBRACK {          | direct_abstract_declarator T_LBRACK array_size T_RBRACK {
                 $$ = add_array($1, true, to_int_constant($3, false));                  $$ = add_array($1, true, to_int_constant($3, false));
           }            }
         | abstract_decl_param_list asm_or_symbolrename_opt {          | abstract_decl_param_list asm_or_symbolrename_opt {
Line 1305  direct_abstract_declarator_postfix: /* C
Line 1380  direct_abstract_declarator_postfix: /* C
                 end_declaration_level();                  end_declaration_level();
                 block_level--;                  block_level--;
           }            }
         | direct_abstract_declarator_postfix abstract_decl_param_list          | direct_abstract_declarator abstract_decl_param_list asm_or_symbolrename_opt {
             asm_or_symbolrename_opt {  
                 $$ = add_function(symbolrename($1, $3), $2);                  $$ = add_function(symbolrename($1, $3), $2);
                 end_declaration_level();                  end_declaration_level();
                 block_level--;                  block_level--;
           }            }
         | direct_abstract_declarator_postfix type_attribute          | direct_abstract_declarator type_attribute_list
         ;  
   
 array_size:  
           type_qualifier_list_opt T_SCLASS constant_expr {  
                 /* C11 6.7.6.3p7 */  
                 if ($2 != STATIC)  
                         yyerror("Bad attribute");  
                 /* static array size is a C11 extension */  
                 c11ism(343);  
                 $$ = $3;  
           }  
         | constant_expr  
         ;          ;
   
 non_expr_statement:  non_expr_statement:
           gcc_attribute T_SEMI            type_attribute T_SEMI
         | labeled_statement          | labeled_statement
         | compound_statement          | compound_statement
         | selection_statement          | selection_statement
Line 1344  statement:   /* C99 6.8 */
Line 1406  statement:   /* C99 6.8 */
         ;          ;
   
 labeled_statement:              /* C99 6.8.1 */  labeled_statement:              /* C99 6.8.1 */
           label gcc_attribute_list_opt statement            label type_attribute_opt statement
         ;          ;
   
 label:  label:
Line 1368  label:
Line 1430  label:
         ;          ;
   
 compound_statement:             /* C99 6.8.2 */  compound_statement:             /* C99 6.8.2 */
           compound_statement_lbrace block_item_list_opt            compound_statement_lbrace compound_statement_rbrace
             compound_statement_rbrace          | compound_statement_lbrace block_item_list compound_statement_rbrace
         ;          ;
   
 compound_statement_lbrace:  compound_statement_lbrace:
Line 1390  compound_statement_rbrace:
Line 1452  compound_statement_rbrace:
           }            }
         ;          ;
   
 block_item_list_opt:            /* C99 6.8.2 */  
           /* empty */  
         | block_item_list  
         ;  
   
 block_item_list:                /* C99 6.8.2 */  block_item_list:                /* C99 6.8.2 */
           block_item            block_item
         | block_item_list block_item {          | block_item_list block_item {
Line 1472  switch_expr:   /* see C99 6.8.4 */
Line 1529  switch_expr:   /* see C99 6.8.4 */
           }            }
         ;          ;
   
 iteration_statement:            /* C99 6.8.5 */  do_statement:                   /* C99 6.8.5 */
           T_WHILE T_LPAREN expr T_RPAREN {            do statement {
                 while1($3);  
                 clear_warning_flags();                  clear_warning_flags();
           } iteration_body {            }
           ;
   
   iteration_statement:            /* C99 6.8.5 */
             while_expr statement {
                 clear_warning_flags();                  clear_warning_flags();
                 while2();                  while2();
           }            }
         | do statement {          | while_expr error {
                 clear_warning_flags();                  clear_warning_flags();
           } T_WHILE T_LPAREN expr T_RPAREN T_SEMI {                  while2();
                 do2($6);            }
           | do_statement do_while_expr {
                   do2($2);
                 seen_fallthrough = false;                  seen_fallthrough = false;
           }            }
         | do error {          | do error {
                 clear_warning_flags();                  clear_warning_flags();
                 do2(NULL);                  do2(NULL);
           }            }
         | for_exprs iteration_body {          | for_exprs statement {
                   clear_warning_flags();
                   for2();
                   end_declaration_level();
                   block_level--;
             }
           | for_exprs error {
                 clear_warning_flags();                  clear_warning_flags();
                 for2();                  for2();
                 end_declaration_level();                  end_declaration_level();
Line 1498  iteration_statement:  /* C99 6.8.5 */
Line 1566  iteration_statement:  /* C99 6.8.5 */
           }            }
         ;          ;
   
 iteration_body:  while_expr:
           statement            T_WHILE T_LPAREN expr T_RPAREN {
         | error                  while1($3);
                   clear_warning_flags();
             }
         ;          ;
   
 do:                             /* see C99 6.8.5 */  do:                             /* see C99 6.8.5 */
Line 1509  do:    /* see C99 6.8.5 */
Line 1579  do:    /* see C99 6.8.5 */
           }            }
         ;          ;
   
   do_while_expr:
             T_WHILE T_LPAREN expr T_RPAREN T_SEMI {
                   $$ = $3;
             }
           ;
   
 for_start:                      /* see C99 6.8.5 */  for_start:                      /* see C99 6.8.5 */
           T_FOR T_LPAREN {            T_FOR T_LPAREN {
                 begin_declaration_level(AUTO);                  begin_declaration_level(AUTO);
Line 1517  for_start:   /* see C99 6.8.5 */
Line 1593  for_start:   /* see C99 6.8.5 */
         ;          ;
   
 for_exprs:                      /* see C99 6.8.5 */  for_exprs:                      /* see C99 6.8.5 */
           for_start            for_start begin_type_declaration_specifiers end_type notype_init_decls T_SEMI
             begin_type declaration_specifiers end_type notype_init_decls T_SEMI              expr_opt T_SEMI expr_opt T_RPAREN {
             expr_opt T_SEMI  
             expr_opt T_RPAREN {  
                 /* variable declaration in for loop */                  /* variable declaration in for loop */
                 c99ism(325);                  c99ism(325);
                 for1(NULL, $7, $9);                  for1(NULL, $6, $8);
                 clear_warning_flags();                  clear_warning_flags();
             }              }
           | for_start expr_opt T_SEMI expr_opt T_SEMI expr_opt T_RPAREN {            | for_start expr_opt T_SEMI expr_opt T_SEMI expr_opt T_RPAREN {
Line 1740  term:    /* see C99 6.5.1 */
Line 1814  term:    /* see C99 6.5.1 */
         | T_EXTENSION term {          | T_EXTENSION term {
                 $$ = $2;                  $$ = $2;
           }            }
           | T_REAL T_LPAREN term T_RPAREN {
                   $$ = build(REAL, $3, NULL);
             }
           | T_IMAG T_LPAREN term T_RPAREN {
                   $$ = build(IMAG, $3, NULL);
             }
         | T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN {          | T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN {
                 symtyp = FMEMBER;                  symtyp = FMEMBER;
                 $$ = build_offsetof($3, getsym($5));                  $$ = build_offsetof($3, getsym($5));
Line 1877  point_or_arrow:
Line 1957  point_or_arrow:
           }            }
         ;          ;
   
 identifier_sym_opt:  
           /* empty */ {  
                 $$ = NULL;  
           }  
         | identifier_sym  
         ;  
   
 identifier_sym:  identifier_sym:
           identifier {            identifier {
                 $$ = getsym($1);                  $$ = getsym($1);
Line 1906  comma_opt:
Line 1979  comma_opt:
         | T_COMMA          | T_COMMA
         ;          ;
   
 /* GCC extensions */  
   
 gcc_attribute_list_opt:  
           /* empty */  
         | gcc_attribute_list  
         ;  
   
 gcc_attribute_list:  
           gcc_attribute  
         | gcc_attribute_list gcc_attribute  
         ;  
   
 /* https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html */  
 gcc_attribute:  
           T_ATTRIBUTE T_LPAREN T_LPAREN {  
                 attron = true;  
           } gcc_attribute_spec_list {  
                 attron = false;  
           } T_RPAREN T_RPAREN  
         ;  
   
 gcc_attribute_spec_list:  gcc_attribute_spec_list:
           gcc_attribute_spec            gcc_attribute_spec
         | gcc_attribute_spec_list T_COMMA gcc_attribute_spec          | gcc_attribute_spec_list T_COMMA gcc_attribute_spec

Legend:
Removed from v.1.305  
changed lines
  Added in v.1.306

CVSweb <webmaster@jp.NetBSD.org>