History

tcc don't understand am extern array of structs. A regression was found trying to compile a linux kernel 2.4.26 which can be compiled by tcc 0.9.23

/////////////////// #include <stdio.h> // test for a bug: // compiler don't understand am extern array of structs // $ tcc test_1.c // test_1.c:8: error: unknown struct/union/enum extern struct FILE std_files[4]; int main() { return 0; } ////////////////// tcc-current /* enum/struct/union declaration. u is either VT_ENUM or VT_STRUCT */ static void struct_decl(CType *type, int u, int tdef) ... if (tok != '{') { v = tok; next(); /* struct already defined ? return it */ if (v < TOK_IDENT) expect("struct/union/enum name"); s = struct_find(v); if (s) { if (s->type.t != a) tcc_error("invalid type"); goto do_decl; } else if (tok >= TOK_IDENT && !tdef) tcc_error("unknown struct/union/enum"); } else { v = anon_sym++; } tcc-0.9.23 which don't have such error /* enum/struct/union declaration. u is either VT_ENUM or VT_STRUCT */ static void struct_decl(CType *type, int u) .... if (tok != '{') { v = tok; next(); /* struct already defined ? return it */ if (v < TOK_IDENT) expect("struct/union/enum name"); s = struct_find(v); if (s) { if (s->type.t != a) error("invalid type"); goto do_decl; } } else { v = anon_sym++; }

seyko committed 11 years ago

Commit bbf82211 parent a429d401 file · +2 −2Browse files

Unified · Split

tccgen.c+2−2
@@ -3148,14 +3148,14 @@ static int parse_btype(CType *type, AttributeDef *ad) · 3147 unmodified lines
31483148 }
31493149 break;
31503150 case TOK_ENUM:
3151− struct_decl(&type1, VT_ENUM, t & VT_TYPEDEF);
3151+ struct_decl(&type1, VT_ENUM, t & (VT_TYPEDEF | VT_EXTERN));
31523152 basic_type2:
31533153 u = type1.t;
31543154 type->ref = type1.ref;
31553155 goto basic_type1;
31563156 case TOK_STRUCT:
31573157 case TOK_UNION:
3158− struct_decl(&type1, VT_STRUCT, t & VT_TYPEDEF);
3158+ struct_decl(&type1, VT_STRUCT, t & (VT_TYPEDEF | VT_EXTERN));
31593159 goto basic_type2;
31603160
31613161 /* type modifiers */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t