@@ -1263,7 +1263,7 @@ static void patch_type(Sym *sym, CType *type)
12631263 } else {
12641264 if ((sym -> type .t & VT_ARRAY ) && type -> ref -> c >= 0 ) {
12651265 /* set array size if it was omitted in extern declaration */
1266- sym -> type .ref = type -> ref ;
1266+ sym -> type .ref -> c = type -> ref -> c ;
12671267 }
12681268 if ((type -> t ^ sym -> type .t ) & VT_STATIC )
12691269 tcc_warning ("storage mismatch for redefinition of '%s'" ,
@@ -4890,6 +4890,8 @@ static int parse_btype(CType *type, AttributeDef *ad, int ignore_label)
48904890 sym_to_attr (ad , s );
48914891 typespec_found = 1 ;
48924892 st = bt = -2 ;
4893+ if (type -> ref && (t & VT_ARRAY ) && type -> ref -> c < 0 )
4894+ type -> ref = sym_push (SYM_FIELD , & type -> ref -> type , 0 , type -> ref -> c );
48934895 break ;
48944896 }
48954897 type_found = 1 ;
@@ -4992,15 +4994,15 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
49924994 type_decl (& pt , & ad1 , & n , TYPE_DIRECT | TYPE_ABSTRACT | TYPE_PARAM );
49934995 if ((pt .t & VT_BTYPE ) == VT_VOID )
49944996 tcc_error ("parameter declared as void" );
4995- if (n == 0 )
4997+ if (local_scope > 1 || n == 0 )
49964998 n = SYM_FIELD ;
49974999 } else {
49985000 n = tok ;
49995001 pt .t = VT_INT | VT_EXTERN ; /* default type */
50005002 pt .ref = NULL ;
50015003 next ();
50025004 }
5003- if (n < TOK_UIDENT )
5005+ if (local_scope == 1 && n < TOK_UIDENT )
50045006 expect ("identifier" );
50055007 convert_parameter_type (& pt );
50065008 arg_size += (type_size (& pt , & align ) + PTR_SIZE - 1 ) / PTR_SIZE ;
@@ -8685,7 +8687,9 @@ static int decl(int l)
86858687 sym = type .ref ;
86868688 if (sym -> f .func_type == FUNC_OLD && l == VT_CONST ) {
86878689 func_vt = type ;
8690+ ++ local_scope ;
86888691 decl (VT_CMP );
8692+ -- local_scope ;
86898693 }
86908694 if ((type .t & (VT_EXTERN |VT_INLINE )) == (VT_EXTERN |VT_INLINE )) {
86918695 /* always_inline functions must be handled as if they
0 commit comments