History

refactor enums

Eliminate VT_ENUM as a basic type. Instead use the integral types VT_InT/VT_LLONG with an additional flag to indicate that it is an enum.

grischka committed 9 years ago

Commit f87afa71 parent 9ba76ac4 files · +107 −102Browse files

Unified · Split

4 files
  1. arm64-gen.c +0 −1
  2. tcc.h +18 −13
  3. tccgen.c +83 −84
  4. x86_64-gen.c +6 −4
arm64-gen.c+0−1
@@ -249,7 +249,6 @@ static int arm64_type_size(int t) · 248 unmodified lines
249 case VT_BYTE: return 0;249 case VT_BYTE: return 0;
250 case VT_SHORT: return 1;250 case VT_SHORT: return 1;
251 case VT_PTR: return 3;251 case VT_PTR: return 3;
252 case VT_ENUM: return 2;
253 case VT_FUNC: return 3;252 case VT_FUNC: return 3;
254 case VT_FLOAT: return 2;253 case VT_FLOAT: return 2;
255 case VT_DOUBLE: return 3;254 case VT_DOUBLE: return 3;
tcc.h+18−13
@@ -416,8 +416,7 @@ struct SymAttr { · 415 unmodified lines
416 visibility : 2,416 visibility : 2,
417 dllexport : 1,417 dllexport : 1,
418 dllimport : 1,418 dllimport : 1,
419 unsigned_enum : 1,419 unused : 5;
420 unused : 4;
421};420};
422 421
423/* function attributes or temporary attributes for parsing */422/* function attributes or temporary attributes for parsing */
@@ -852,14 +851,13 @@ struct filespec { · 428 unmodified lines
852#define VT_PTR 5 /* pointer */851#define VT_PTR 5 /* pointer */
853#define VT_FUNC 6 /* function type */852#define VT_FUNC 6 /* function type */
854#define VT_STRUCT 7 /* struct/union definition */853#define VT_STRUCT 7 /* struct/union definition */
855#define VT_ENUM 8 /* enum definition */854#define VT_FLOAT 8 /* IEEE float */
856#define VT_FLOAT 9 /* IEEE float */855#define VT_DOUBLE 9 /* IEEE double */
857#define VT_DOUBLE 10 /* IEEE double */856#define VT_LDOUBLE 10 /* IEEE long double */
858#define VT_LDOUBLE 11 /* IEEE long double */857#define VT_BOOL 11 /* ISOC99 boolean type */
859#define VT_BOOL 12 /* ISOC99 boolean type */858#define VT_LONG 12 /* long integer (NEVER USED as type, only during parsing) */
860#define VT_LONG 13 /* long integer (NEVER USED as type, only during parsing) */859#define VT_QLONG 13 /* 128-bit integer. Only used for x86-64 ABI */
861#define VT_QLONG 14 /* 128-bit integer. Only used for x86-64 ABI */860#define VT_QFLOAT 14 /* 128-bit float. Only used for x86-64 ABI */
862#define VT_QFLOAT 15 /* 128-bit float. Only used for x86-64 ABI */
863 861
864#define VT_UNSIGNED 0x0010 /* unsigned type */862#define VT_UNSIGNED 0x0010 /* unsigned type */
865#define VT_DEFSIGN 0x0020 /* explicitly signed or unsigned */863#define VT_DEFSIGN 0x0020 /* explicitly signed or unsigned */
@@ -868,7 +866,6 @@ struct filespec { · 2 unmodified lines
868#define VT_CONSTANT 0x0100 /* const modifier */866#define VT_CONSTANT 0x0100 /* const modifier */
869#define VT_VOLATILE 0x0200 /* volatile modifier */867#define VT_VOLATILE 0x0200 /* volatile modifier */
870#define VT_VLA 0x0400 /* VLA type (also has VT_PTR and VT_ARRAY) */868#define VT_VLA 0x0400 /* VLA type (also has VT_PTR and VT_ARRAY) */
871#define VT_UNION (VT_STRUCT|VT_UNSIGNED) /* VT_STRUCT type with some modifier */
872 869
873/* storage */870/* storage */
874#define VT_EXTERN 0x00001000 /* extern definition */871#define VT_EXTERN 0x00001000 /* extern definition */
@@ -882,9 +879,17 @@ struct filespec { · 7 unmodified lines
882#define BIT_POS(t) (((t) >> VT_STRUCT_SHIFT) & 0x3f)879#define BIT_POS(t) (((t) >> VT_STRUCT_SHIFT) & 0x3f)
883#define BIT_SIZE(t) (((t) >> (VT_STRUCT_SHIFT + 6)) & 0x3f)880#define BIT_SIZE(t) (((t) >> (VT_STRUCT_SHIFT + 6)) & 0x3f)
884 881
882#define VT_UNION (1 << VT_STRUCT_SHIFT | VT_STRUCT)
883#define VT_ENUM (2 << VT_STRUCT_SHIFT) /* integral type is an enum really */
884#define VT_ENUM_VAL (3 << VT_STRUCT_SHIFT) /* integral type is an enum constant really */
885
886#define IS_ENUM(t) ((t & VT_STRUCT_MASK) == VT_ENUM)
887#define IS_ENUM_VAL(t) ((t & VT_STRUCT_MASK) == VT_ENUM_VAL)
888#define IS_UNION(t) ((t & (VT_STRUCT_MASK|VT_BTYPE)) == VT_UNION)
889
885/* type mask (except storage) */890/* type mask (except storage) */
886#define VT_STORAGE (VT_EXTERN | VT_STATIC | VT_TYPEDEF | VT_INLINE | VT_STRUCT_MASK)891#define VT_STORAGE (VT_EXTERN | VT_STATIC | VT_TYPEDEF | VT_INLINE)
887#define VT_TYPE (~VT_STORAGE)892#define VT_TYPE (~(VT_STORAGE|VT_STRUCT_MASK))
888 893
889 894
890/* token values */895/* token values */
tccgen.c+83−84
@@ -86,7 +86,7 @@ static void expr_eq(void); · 85 unmodified lines
86static void vla_runtime_type_size(CType *type, int *a);86static void vla_runtime_type_size(CType *type, int *a);
87static void vla_sp_restore(void);87static void vla_sp_restore(void);
88static void vla_sp_restore_root(void);88static void vla_sp_restore_root(void);
89static int is_compatible_parameter_types(CType *type1, CType *type2);89static int is_compatible_unqualified_types(CType *type1, CType *type2);
90static inline int64_t expr_const64(void);90static inline int64_t expr_const64(void);
91ST_FUNC void vpush64(int ty, unsigned long long v);91ST_FUNC void vpush64(int ty, unsigned long long v);
92ST_FUNC void vpush(CType *type);92ST_FUNC void vpush(CType *type);
@@ -1087,10 +1087,8 @@ ST_FUNC int gv(int rc) · 994 unmodified lines
1087 bits = 64;1087 bits = 64;
1088 } else1088 } else
1089 type.t = VT_INT;1089 type.t = VT_INT;
1090 if((vtop->type.t & VT_UNSIGNED) ||1090 if((vtop->type.t & VT_UNSIGNED)
1091 (vtop->type.t & VT_BTYPE) == VT_BOOL ||1091 || (vtop->type.t & VT_BTYPE) == VT_BOOL)
1092 (((vtop->type.t & VT_BTYPE) == VT_ENUM) &&
1093 vtop->type.ref->a.unsigned_enum))
1094 type.t |= VT_UNSIGNED;1092 type.t |= VT_UNSIGNED;
1095 gen_cast(&type);1093 gen_cast(&type);
1096 /* generate shifts */1094 /* generate shifts */
@@ -2479,6 +2477,8 @@ ST_FUNC int type_size(CType *type, int *a) · 1382 unmodified lines
2479 *a = PTR_SIZE;2477 *a = PTR_SIZE;
2480 return PTR_SIZE;2478 return PTR_SIZE;
2481 }2479 }
2480 } else if (IS_ENUM(type->t) && type->ref->c == -1) {
2481 return -1; /* incomplete enum */
2482 } else if (bt == VT_LDOUBLE) {2482 } else if (bt == VT_LDOUBLE) {
2483 *a = LDOUBLE_ALIGN;2483 *a = LDOUBLE_ALIGN;
2484 return LDOUBLE_SIZE;2484 return LDOUBLE_SIZE;
@@ -2508,10 +2508,6 @@ ST_FUNC int type_size(CType *type, int *a) · 23 unmodified lines
2508 } else if (bt == VT_QLONG || bt == VT_QFLOAT) {2508 } else if (bt == VT_QLONG || bt == VT_QFLOAT) {
2509 *a = 8;2509 *a = 8;
2510 return 16;2510 return 16;
2511 } else if (bt == VT_ENUM) {
2512 *a = 4;
2513 /* Enums might be incomplete, so don't just return '4' here. */
2514 return type->ref->c;
2515 } else {2511 } else {
2516 /* char, void, function, _Bool */2512 /* char, void, function, _Bool */
2517 *a = 1;2513 *a = 1;
@@ -2554,7 +2550,7 @@ ST_FUNC void mk_pointer(CType *type) · 36 unmodified lines
2554{2550{
2555 Sym *s;2551 Sym *s;
2556 s = sym_push(SYM_FIELD, type, 0, -1);2552 s = sym_push(SYM_FIELD, type, 0, -1);
2557 type->t = VT_PTR | (type->t & ~VT_TYPE);2553 type->t = VT_PTR | (type->t & VT_STORAGE);
2558 type->ref = s;2554 type->ref = s;
2559}2555}
2560 2556
@@ -2578,7 +2574,7 @@ static int is_compatible_func(CType *type1, CType *type2) · 17 unmodified lines
2578 while (s1 != NULL) {2574 while (s1 != NULL) {
2579 if (s2 == NULL)2575 if (s2 == NULL)
2580 return 0;2576 return 0;
2581 if (!is_compatible_parameter_types(&s1->type, &s2->type))2577 if (!is_compatible_unqualified_types(&s1->type, &s2->type))
2582 return 0;2578 return 0;
2583 s1 = s1->next;2579 s1 = s1->next;
2584 s2 = s2->next;2580 s2 = s2->next;
@@ -2609,21 +2605,7 @@ static int compare_types(CType *type1, CType *type2, int unqualified) · 24 unmodified lines
2609 t1 &= ~VT_DEFSIGN;2605 t1 &= ~VT_DEFSIGN;
2610 t2 &= ~VT_DEFSIGN;2606 t2 &= ~VT_DEFSIGN;
2611 }2607 }
2612 /* An enum is compatible with (unsigned) int. Ideally we would2608
2613 store the enums signedness in type->ref.a.<some_bit> and
2614 only accept unsigned enums with unsigned int and vice versa.
2615 But one of our callers (gen_assign_cast) always strips VT_UNSIGNED
2616 from pointer target types, so we can't add it here either. */
2617 if ((t1 & VT_BTYPE) == VT_ENUM) {
2618 t1 = VT_INT;
2619 if (type1->ref->a.unsigned_enum)
2620 t1 |= VT_UNSIGNED;
2621 }
2622 if ((t2 & VT_BTYPE) == VT_ENUM) {
2623 t2 = VT_INT;
2624 if (type2->ref->a.unsigned_enum)
2625 t2 |= VT_UNSIGNED;
2626 }
2627 /* XXX: bitfields ? */2609 /* XXX: bitfields ? */
2628 if (t1 != t2)2610 if (t1 != t2)
2629 return 0;2611 return 0;
@@ -2652,7 +2634,7 @@ static int is_compatible_types(CType *type1, CType *type2) · 22 unmodified lines
2652 2634
2653/* return true if type1 and type2 are the same (ignoring qualifiers).2635/* return true if type1 and type2 are the same (ignoring qualifiers).
2654*/2636*/
2655static int is_compatible_parameter_types(CType *type1, CType *type2)2637static int is_compatible_unqualified_types(CType *type1, CType *type2)
2656{2638{
2657 return compare_types(type1,type2,1);2639 return compare_types(type1,type2,1);
2658}2640}
@@ -2690,6 +2672,10 @@ static void type_to_str(char *buf, int buf_size, · 31 unmodified lines
2690 pstrcat(buf, buf_size, "inline ");2672 pstrcat(buf, buf_size, "inline ");
2691 buf_size -= strlen(buf);2673 buf_size -= strlen(buf);
2692 buf += strlen(buf);2674 buf += strlen(buf);
2675 if (IS_ENUM(type->t)) {
2676 tstr = "enum ";
2677 goto tstruct;
2678 }
2693 switch(bt) {2679 switch(bt) {
2694 case VT_VOID:2680 case VT_VOID:
2695 tstr = "void";2681 tstr = "void";
@@ -2723,12 +2709,11 @@ static void type_to_str(char *buf, int buf_size, · 27 unmodified lines
2723 add_tstr:2709 add_tstr:
2724 pstrcat(buf, buf_size, tstr);2710 pstrcat(buf, buf_size, tstr);
2725 break;2711 break;
2726 case VT_ENUM:
2727 case VT_STRUCT:2712 case VT_STRUCT:
2728 if (bt == VT_STRUCT)2713 tstr = "struct ";
2729 tstr = "struct ";2714 if (IS_UNION(t))
2730 else2715 tstr = "union ";
2731 tstr = "enum ";2716 tstruct:
2732 pstrcat(buf, buf_size, tstr);2717 pstrcat(buf, buf_size, tstr);
2733 v = type->ref->v & ~SYM_STRUCT;2718 v = type->ref->v & ~SYM_STRUCT;
2734 if (v >= SYM_FIRST_ANOM)2719 if (v >= SYM_FIRST_ANOM)
@@ -2827,21 +2812,16 @@ static void gen_assign_cast(CType *dt) · 92 unmodified lines
2827 (type2->t & VT_BTYPE) == VT_VOID) {2812 (type2->t & VT_BTYPE) == VT_VOID) {
2828 /* void * can match anything */2813 /* void * can match anything */
2829 } else {2814 } else {
2815 //printf("types %08x %08x\n", type1->t, type2->t);
2830 /* exact type match, except for qualifiers */2816 /* exact type match, except for qualifiers */
2831 tmp_type1 = *type1;2817 if (!is_compatible_unqualified_types(type1, type2)) {
2832 tmp_type2 = *type2;
2833 tmp_type1.t &= ~(VT_CONSTANT | VT_VOLATILE);
2834 tmp_type2.t &= ~(VT_CONSTANT | VT_VOLATILE);
2835 if (!is_compatible_types(&tmp_type1, &tmp_type2)) {
2836 /* Like GCC don't warn by default for merely changes2818 /* Like GCC don't warn by default for merely changes
2837 in pointer target signedness. Do warn for different2819 in pointer target signedness. Do warn for different
2838 base types, though, in particular for unsigned enums2820 base types, though, in particular for unsigned enums
2839 and signed int targets. */2821 and signed int targets. */
2840 if ((tmp_type1.t & (VT_DEFSIGN | VT_UNSIGNED)) !=2822 if ((type1->t & VT_BTYPE) != (type2->t & VT_BTYPE)
2841 (tmp_type2.t & (VT_DEFSIGN | VT_UNSIGNED)) &&2823 || IS_ENUM(type1->t) || IS_ENUM(type2->t)
2842 (tmp_type1.t & VT_BTYPE) == (tmp_type2.t & VT_BTYPE))2824 )
2843 ;
2844 else
2845 tcc_warning("assignment from incompatible pointer type");2825 tcc_warning("assignment from incompatible pointer type");
2846 }2826 }
2847 }2827 }
@@ -3486,7 +3466,7 @@ static void struct_layout(CType *type, AttributeDef *ad) · 638 unmodified lines
3486 tcc_warning("will touch memory past end of the struct (internal limitation)");3466 tcc_warning("will touch memory past end of the struct (internal limitation)");
3487}3467}
3488 3468
3489/* enum/struct/union declaration. u is either VT_ENUM or VT_STRUCT */3469/* enum/struct/union declaration. u is VT_ENUM/VT_STRUCT/VT_UNION */
3490static void struct_decl(CType *type, int u)3470static void struct_decl(CType *type, int u)
3491{3471{
3492 int v, c, size, align, flexible, alignoverride;3472 int v, c, size, align, flexible, alignoverride;
@@ -3506,9 +3486,11 @@ static void struct_decl(CType *type, int u) · 13 unmodified lines
3506 expect("struct/union/enum name");3486 expect("struct/union/enum name");
3507 s = struct_find(v);3487 s = struct_find(v);
3508 if (s && (s->sym_scope == local_scope || tok != '{')) {3488 if (s && (s->sym_scope == local_scope || tok != '{')) {
3509 if ((s->type.t & (VT_BTYPE|VT_UNION)) != u)3489 if (u == s->type.t)
3510 tcc_error("redefinition of '%s'", get_tok_str(v, NULL));3490 goto do_decl;
3511 goto do_decl;3491 if (u == VT_ENUM && IS_ENUM(s->type.t))
3492 goto do_decl;
3493 tcc_error("redefinition of '%s'", get_tok_str(v, NULL));
3512 }3494 }
3513 } else {3495 } else {
3514 v = anon_sym++;3496 v = anon_sym++;
@@ -3520,7 +3502,7 @@ static void struct_decl(CType *type, int u) · 5 unmodified lines
3520 s = sym_push(v | SYM_STRUCT, &type1, 0, -1);3502 s = sym_push(v | SYM_STRUCT, &type1, 0, -1);
3521 s->r = 0; /* default alignment is zero as gcc */3503 s->r = 0; /* default alignment is zero as gcc */
3522do_decl:3504do_decl:
3523 type->t = u & VT_BTYPE; /* VT_UNION becomes VT_STRUCT */3505 type->t = s->type.t;
3524 type->ref = s;3506 type->ref = s;
3525 3507
3526 if (tok == '{') {3508 if (tok == '{') {
@@ -3528,13 +3510,15 @@ do_decl: · 1 unmodified line
3528 if (s->c != -1)3510 if (s->c != -1)
3529 tcc_error("struct/union/enum already defined");3511 tcc_error("struct/union/enum already defined");
3530 /* cannot be empty */3512 /* cannot be empty */
3531 c = 0;
3532 /* non empty enums are not allowed */3513 /* non empty enums are not allowed */
3514 ps = &s->next;
3533 if (u == VT_ENUM) {3515 if (u == VT_ENUM) {
3534 int seen_neg = 0;3516 long long ll = 0, pl = 0, nl = 0;
3535 int seen_wide = 0;3517 CType t;
3518 t.ref = s;
3519 /* enum symbols have static storage */
3520 t.t = VT_INT|VT_STATIC|VT_ENUM_VAL;
3536 for(;;) {3521 for(;;) {
3537 CType *t = &int_type;
3538 v = tok;3522 v = tok;
3539 if (v < TOK_UIDENT)3523 if (v < TOK_UIDENT)
3540 expect("identifier");3524 expect("identifier");
@@ -3545,38 +3529,48 @@ do_decl: · 4 unmodified lines
3545 next();3529 next();
3546 if (tok == '=') {3530 if (tok == '=') {
3547 next();3531 next();
3548#if PTR_SIZE == 83532 ll = expr_const64();
3549 c = expr_const64();
3550#else
3551 /* We really want to support long long enums
3552 on i386 as well, but the Sym structure only
3553 holds a 'long' for associated constants,
3554 and enlarging it would bump its size (no
3555 available padding). So punt for now. */
3556 c = expr_const();
3557#endif
3558 }3533 }
3559 if (c < 0)3534 ss = sym_push(v, &t, VT_CONST, 0);
3560 seen_neg = 1;3535 ss->enum_val = ll;
3561 if (c != (int)c && (unsigned long)c != (unsigned int)c)3536 *ps = ss, ps = &ss->next;
3562 seen_wide = 1, t = &size_type;3537 if (ll < nl)
3563 /* enum symbols have static storage */3538 nl = ll;
3564 ss = sym_push(v, t, VT_CONST, c);3539 if (ll > pl)
3565 ss->type.t |= VT_STATIC;3540 pl = ll;
3566 if (tok != ',')3541 if (tok != ',')
3567 break;3542 break;
3568 next();3543 next();
3569 c++;3544 ll++;
3570 /* NOTE: we accept a trailing comma */3545 /* NOTE: we accept a trailing comma */
3571 if (tok == '}')3546 if (tok == '}')
3572 break;3547 break;
3573 }3548 }
3574 if (!seen_neg)
3575 s->a.unsigned_enum = 1;
3576 s->c = type_size(seen_wide ? &size_type : &int_type, &align);
3577 skip('}');3549 skip('}');
3550 /* set integral type of the enum */
3551 t.t = VT_INT;
3552 if (nl == 0) {
3553 if (pl != (unsigned)pl)
3554 t.t = VT_LLONG;
3555 t.t |= VT_UNSIGNED;
3556 } else if (pl != (int)pl || nl != (int)nl)
3557 t.t = VT_LLONG;
3558 s->type.t = type->t = t.t | VT_ENUM;
3559 s->c = 0;
3560 /* set type for enum members */
3561 for (ss = s->next; ss; ss = ss->next) {
3562 ll = ss->enum_val;
3563 if (ll == (int)ll) /* default is int if it fits */
3564 continue;
3565 if (t.t & VT_UNSIGNED) {
3566 ss->type.t |= VT_UNSIGNED;
3567 if (ll == (unsigned)ll)
3568 continue;
3569 }
3570 ss->type.t = (ss->type.t & ~VT_BTYPE) | VT_LLONG;
3571 }
3578 } else {3572 } else {
3579 ps = &s->next;3573 c = 0;
3580 flexible = 0;3574 flexible = 0;
3581 while (tok != '}') {3575 while (tok != '}') {
3582 if (!parse_btype(&btype, &ad1)) {3576 if (!parse_btype(&btype, &ad1)) {
@@ -3646,7 +3640,6 @@ do_decl: · 63 unmodified lines
3646 bt != VT_BYTE && 3640 bt != VT_BYTE &&
3647 bt != VT_SHORT &&3641 bt != VT_SHORT &&
3648 bt != VT_BOOL &&3642 bt != VT_BOOL &&
3649 bt != VT_ENUM &&
3650 bt != VT_LLONG)3643 bt != VT_LLONG)
3651 tcc_error("bitfields must have scalar type");3644 tcc_error("bitfields must have scalar type");
3652 bsize = size * 8;3645 bsize = size * 8;
@@ -3657,9 +3650,9 @@ do_decl: · 4 unmodified lines
3657 /* no need for bit fields */3650 /* no need for bit fields */
3658 ;3651 ;
3659 } else {3652 } else {
3660 type1.t |= VT_BITFIELD | 3653 type1.t = (type1.t & ~VT_STRUCT_MASK)
3661 (0 << VT_STRUCT_SHIFT) |3654 | VT_BITFIELD
3662 (bit_size << (VT_STRUCT_SHIFT + 6));3655 | (bit_size << (VT_STRUCT_SHIFT + 6));
3663 }3656 }
3664 }3657 }
3665 if (v != 0 || (type1.t & VT_BTYPE) == VT_STRUCT) {3658 if (v != 0 || (type1.t & VT_BTYPE) == VT_STRUCT) {
@@ -4124,6 +4117,7 @@ static CType *type_decl(CType *type, AttributeDef *ad, int *v, int td) · 458 unmodified lines
4124 storage = type->t & VT_STORAGE;4117 storage = type->t & VT_STORAGE;
4125 type->t &= ~VT_STORAGE;4118 type->t &= ~VT_STORAGE;
4126 post = ret = type;4119 post = ret = type;
4120
4127 while (tok == '*') {4121 while (tok == '*') {
4128 qualifiers = 0;4122 qualifiers = 0;
4129 redo:4123 redo:
@@ -4813,8 +4807,11 @@ ST_FUNC void unary(void) · 683 unmodified lines
4813 Will be used by at least the x86 inline asm parser for4807 Will be used by at least the x86 inline asm parser for
4814 regvars. */4808 regvars. */
4815 vtop->sym = s;4809 vtop->sym = s;
4816 if (vtop->r & VT_SYM) {4810
4811 if (r & VT_SYM) {
4817 vtop->c.i = 0;4812 vtop->c.i = 0;
4813 } else if (r == VT_CONST && IS_ENUM_VAL(s->type.t)) {
4814 vtop->c.i = s->enum_val;
4818 }4815 }
4819 break;4816 break;
4820 }4817 }
@@ -6352,7 +6349,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 1531 unmodified lines
6352 /* Use i_c_parameter_t, to strip toplevel qualifiers.6349 /* Use i_c_parameter_t, to strip toplevel qualifiers.
6353 The source type might have VT_CONSTANT set, which is6350 The source type might have VT_CONSTANT set, which is
6354 of course assignable to non-const elements. */6351 of course assignable to non-const elements. */
6355 is_compatible_parameter_types(type, &vtop->type)) {6352 is_compatible_unqualified_types(type, &vtop->type)) {
6356 init_putv(type, sec, c);6353 init_putv(type, sec, c);
6357 } else if (type->t & VT_ARRAY) {6354 } else if (type->t & VT_ARRAY) {
6358 s = type->ref;6355 s = type->ref;
@@ -6858,16 +6855,18 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym) · 499 unmodified lines
6858 break;6855 break;
6859 btype.t = VT_INT;6856 btype.t = VT_INT;
6860 }6857 }
6861 if (((btype.t & VT_BTYPE) == VT_ENUM ||6858 if (tok == ';') {
6862 (btype.t & VT_BTYPE) == VT_STRUCT) &&
6863 tok == ';') {
6864 if ((btype.t & VT_BTYPE) == VT_STRUCT) {6859 if ((btype.t & VT_BTYPE) == VT_STRUCT) {
6865 int v = btype.ref->v;6860 int v = btype.ref->v;
6866 if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) >= SYM_FIRST_ANOM)6861 if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) >= SYM_FIRST_ANOM)
6867 tcc_warning("unnamed struct/union that defines no instances");6862 tcc_warning("unnamed struct/union that defines no instances");
6863 next();
6864 continue;
6868 }6865 }
6869 next();6866 if (IS_ENUM(btype.t)) {
6870 continue;6867 next();
6868 continue;
6869 }
6871 }6870 }
6872 while (1) { /* iterate thru each declaration */6871 while (1) { /* iterate thru each declaration */
6873 type = btype;6872 type = btype;
x86_64-gen.c+6−4
@@ -415,9 +415,11 @@ void load(int r, SValue *sv) · 414 unmodified lines
415 } else if ((ft & VT_TYPE) == (VT_SHORT | VT_UNSIGNED)) {415 } else if ((ft & VT_TYPE) == (VT_SHORT | VT_UNSIGNED)) {
416 b = 0xb70f; /* movzwl */416 b = 0xb70f; /* movzwl */
417 } else {417 } else {
418 assert(((ft & VT_BTYPE) == VT_INT) || ((ft & VT_BTYPE) == VT_LLONG)418 assert(((ft & VT_BTYPE) == VT_INT)
419 || ((ft & VT_BTYPE) == VT_PTR) || ((ft & VT_BTYPE) == VT_ENUM)419 || ((ft & VT_BTYPE) == VT_LLONG)
420 || ((ft & VT_BTYPE) == VT_FUNC));420 || ((ft & VT_BTYPE) == VT_PTR)
421 || ((ft & VT_BTYPE) == VT_FUNC)
422 );
421 ll = is64_type(ft);423 ll = is64_type(ft);
422 b = 0x8b;424 b = 0x8b;
423 }425 }
@@ -1092,7 +1094,7 @@ static X86_64_Mode classify_x86_64_inner(CType *ty) · 668 unmodified lines
1092 case VT_BOOL:1094 case VT_BOOL:
1093 case VT_PTR:1095 case VT_PTR:
1094 case VT_FUNC:1096 case VT_FUNC:
1095 case VT_ENUM: return x86_64_mode_integer;1097 return x86_64_mode_integer;
1096 1098
1097 case VT_FLOAT:1099 case VT_FLOAT:
1098 case VT_DOUBLE: return x86_64_mode_sse;1100 case VT_DOUBLE: return x86_64_mode_sse;

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