Still some more tabs to be taken care of. arm-gen.c and tcccoff.c have so many style issues that I'm just going to throw clang-format at them.
Showing the changes to tccgen.c (1 of 10 files). Show all
Unified · Split
| @@ -323,7 +323,7 @@ static void apply_visibility(Sym *sym, CType *type) · 322 unmodified lines | ||
| 323 | 323 | ElfW(Sym) *esym; |
| 324 | 324 | |
| 325 | 325 | esym = &((ElfW(Sym) *)symtab_section->data)[sym->c]; |
| 326 | − vis >>= VT_VIS_SHIFT; | |
| 326 | + vis >>= VT_VIS_SHIFT; | |
| 327 | 327 | esym->st_other = (esym->st_other & ~ELFW(ST_VISIBILITY)(-1)) | vis; |
| 328 | 328 | } |
| 329 | 329 | } |
| @@ -1631,7 +1631,7 @@ static inline int is_null_pointer(SValue *p) · 1301 unmodified lines | ||
| 1631 | 1631 | return 0; |
| 1632 | 1632 | return ((p->type.t & VT_BTYPE) == VT_INT && p->c.i == 0) || |
| 1633 | 1633 | ((p->type.t & VT_BTYPE) == VT_LLONG && p->c.ll == 0) || |
| 1634 | − ((p->type.t & VT_BTYPE) == VT_PTR && p->c.ptr_offset == 0); | |
| 1634 | + ((p->type.t & VT_BTYPE) == VT_PTR && p->c.ptr_offset == 0); | |
| 1635 | 1635 | } |
| 1636 | 1636 | |
| 1637 | 1637 | static inline int is_integer_btype(int bt) |
| @@ -1761,18 +1761,18 @@ ST_FUNC void gen_op(int op) · 123 unmodified lines | ||
| 1761 | 1761 | #if 0 |
| 1762 | 1762 | /* #ifdef CONFIG_TCC_BCHECK |
| 1763 | 1763 | The main reason to removing this code: |
| 1764 | − #include <stdio.h> | |
| 1765 | − int main () | |
| 1766 | − { | |
| 1767 | − int v[10]; | |
| 1768 | − int i = 10; | |
| 1769 | − int j = 9; | |
| 1770 | − fprintf(stderr, "v+i-j = %p\n", v+i-j); | |
| 1771 | − fprintf(stderr, "v+(i-j) = %p\n", v+(i-j)); | |
| 1772 | − } | |
| 1764 | + #include <stdio.h> | |
| 1765 | + int main () | |
| 1766 | + { | |
| 1767 | + int v[10]; | |
| 1768 | + int i = 10; | |
| 1769 | + int j = 9; | |
| 1770 | + fprintf(stderr, "v+i-j = %p\n", v+i-j); | |
| 1771 | + fprintf(stderr, "v+(i-j) = %p\n", v+(i-j)); | |
| 1772 | + } | |
| 1773 | 1773 | When this code is on. then the output looks like |
| 1774 | − v+i-j = 0xfffffffe | |
| 1775 | − v+(i-j) = 0xbff84000 | |
| 1774 | + v+i-j = 0xfffffffe | |
| 1775 | + v+(i-j) = 0xbff84000 | |
| 1776 | 1776 | */ |
| 1777 | 1777 | /* if evaluating constant expression, no code should be |
| 1778 | 1778 | generated, so no bound check */ |
| @@ -2450,18 +2450,18 @@ static void gen_assign_cast(CType *dt) · 671 unmodified lines | ||
| 2450 | 2450 | dbt = dt->t & VT_BTYPE; |
| 2451 | 2451 | sbt = st->t & VT_BTYPE; |
| 2452 | 2452 | if (sbt == VT_VOID || dbt == VT_VOID) { |
| 2453 | − if (sbt == VT_VOID && dbt == VT_VOID) | |
| 2454 | − ; /* | |
| 2455 | − It is Ok if both are void | |
| 2456 | − A test program: | |
| 2457 | − void func1() {} | |
| 2458 | − void func2() { | |
| 2459 | − return func1(); | |
| 2460 | − } | |
| 2461 | − gcc accepts this program | |
| 2462 | − */ | |
| 2463 | − else | |
| 2464 | − tcc_error("cannot cast from/to void"); | |
| 2453 | + if (sbt == VT_VOID && dbt == VT_VOID) | |
| 2454 | + ; /* | |
| 2455 | + It is Ok if both are void | |
| 2456 | + A test program: | |
| 2457 | + void func1() {} | |
| 2458 | + void func2() { | |
| 2459 | + return func1(); | |
| 2460 | + } | |
| 2461 | + gcc accepts this program | |
| 2462 | + */ | |
| 2463 | + else | |
| 2464 | + tcc_error("cannot cast from/to void"); | |
| 2465 | 2465 | } |
| 2466 | 2466 | if (dt->t & VT_CONSTANT) |
| 2467 | 2467 | tcc_warning("assignment of read-only location"); |
| @@ -2542,7 +2542,7 @@ ST_FUNC void vstore(void) · 74 unmodified lines | ||
| 2542 | 2542 | dbt = ft & VT_BTYPE; |
| 2543 | 2543 | if ((((sbt == VT_INT || sbt == VT_SHORT) && dbt == VT_BYTE) || |
| 2544 | 2544 | (sbt == VT_INT && dbt == VT_SHORT)) |
| 2545 | − && !(vtop->type.t & VT_BITFIELD)) { | |
| 2545 | + && !(vtop->type.t & VT_BITFIELD)) { | |
| 2546 | 2546 | /* optimize char/short casts */ |
| 2547 | 2547 | delayed_cast = VT_MUSTCAST; |
| 2548 | 2548 | vtop->type.t = ft & (VT_TYPE & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT))); |
| @@ -2764,20 +2764,20 @@ static void parse_attribute(AttributeDef *ad) · 215 unmodified lines | ||
| 2764 | 2764 | next(); |
| 2765 | 2765 | skip(')'); |
| 2766 | 2766 | break; |
| 2767 | − case TOK_VISIBILITY1: | |
| 2768 | − case TOK_VISIBILITY2: | |
| 2767 | + case TOK_VISIBILITY1: | |
| 2768 | + case TOK_VISIBILITY2: | |
| 2769 | 2769 | skip('('); |
| 2770 | 2770 | if (tok != TOK_STR) |
| 2771 | 2771 | expect("visibility(\"default|hidden|internal|protected\")"); |
| 2772 | − if (!strcmp (tokc.cstr->data, "default")) | |
| 2773 | − ad->a.visibility = STV_DEFAULT; | |
| 2774 | − else if (!strcmp (tokc.cstr->data, "hidden")) | |
| 2775 | − ad->a.visibility = STV_HIDDEN; | |
| 2776 | − else if (!strcmp (tokc.cstr->data, "internal")) | |
| 2777 | − ad->a.visibility = STV_INTERNAL; | |
| 2778 | − else if (!strcmp (tokc.cstr->data, "protected")) | |
| 2779 | − ad->a.visibility = STV_PROTECTED; | |
| 2780 | − else | |
| 2772 | + if (!strcmp (tokc.cstr->data, "default")) | |
| 2773 | + ad->a.visibility = STV_DEFAULT; | |
| 2774 | + else if (!strcmp (tokc.cstr->data, "hidden")) | |
| 2775 | + ad->a.visibility = STV_HIDDEN; | |
| 2776 | + else if (!strcmp (tokc.cstr->data, "internal")) | |
| 2777 | + ad->a.visibility = STV_INTERNAL; | |
| 2778 | + else if (!strcmp (tokc.cstr->data, "protected")) | |
| 2779 | + ad->a.visibility = STV_PROTECTED; | |
| 2780 | + else | |
| 2781 | 2781 | expect("visibility(\"default|hidden|internal|protected\")"); |
| 2782 | 2782 | next(); |
| 2783 | 2783 | skip(')'); |
| @@ -2973,8 +2973,8 @@ static void struct_decl(CType *type, int u, int tdef) · 189 unmodified lines | ||
| 2973 | 2973 | while (tok != '}') { |
| 2974 | 2974 | parse_btype(&btype, &ad); |
| 2975 | 2975 | while (1) { |
| 2976 | − if (flexible) | |
| 2977 | − tcc_error("flexible array member '%s' not at the end of struct", | |
| 2976 | + if (flexible) | |
| 2977 | + tcc_error("flexible array member '%s' not at the end of struct", | |
| 2978 | 2978 | get_tok_str(v, NULL)); |
| 2979 | 2979 | bit_size = -1; |
| 2980 | 2980 | v = 0; |
| @@ -2982,21 +2982,21 @@ static void struct_decl(CType *type, int u, int tdef) · 1 unmodified line | ||
| 2982 | 2982 | if (tok != ':') { |
| 2983 | 2983 | type_decl(&type1, &ad, &v, TYPE_DIRECT | TYPE_ABSTRACT); |
| 2984 | 2984 | if (v == 0) { |
| 2985 | − if ((type1.t & VT_BTYPE) != VT_STRUCT) | |
| 2986 | − expect("identifier"); | |
| 2987 | − else { | |
| 2988 | − int v = btype.ref->v; | |
| 2989 | − if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) < SYM_FIRST_ANOM) { | |
| 2990 | − if (tcc_state->ms_extensions == 0) | |
| 2991 | − expect("identifier"); | |
| 2992 | − } | |
| 2993 | − } | |
| 2985 | + if ((type1.t & VT_BTYPE) != VT_STRUCT) | |
| 2986 | + expect("identifier"); | |
| 2987 | + else { | |
| 2988 | + int v = btype.ref->v; | |
| 2989 | + if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) < SYM_FIRST_ANOM) { | |
| 2990 | + if (tcc_state->ms_extensions == 0) | |
| 2991 | + expect("identifier"); | |
| 2992 | + } | |
| 2993 | + } | |
| 2994 | 2994 | } |
| 2995 | 2995 | if (type_size(&type1, &align) < 0) { |
| 2996 | − if ((a == TOK_STRUCT) && (type1.t & VT_ARRAY) && c) | |
| 2997 | − flexible = 1; | |
| 2998 | − else | |
| 2999 | − tcc_error("field '%s' has incomplete type", | |
| 2996 | + if ((a == TOK_STRUCT) && (type1.t & VT_ARRAY) && c) | |
| 2997 | + flexible = 1; | |
| 2998 | + else | |
| 2999 | + tcc_error("field '%s' has incomplete type", | |
| 3000 | 3000 | get_tok_str(v, NULL)); |
| 3001 | 3001 | } |
| 3002 | 3002 | if ((type1.t & VT_BTYPE) == VT_FUNC || |
| @@ -3807,11 +3807,11 @@ ST_FUNC void unary(void) · 804 unmodified lines | ||
| 3807 | 3807 | gen_cast(&type); |
| 3808 | 3808 | } |
| 3809 | 3809 | } else if (tok == '{') { |
| 3810 | − /* | |
| 3810 | + /* | |
| 3811 | 3811 | if (nocode_wanted) |
| 3812 | 3812 | tcc_error("statement expression in global scope"); */ |
| 3813 | − /* this check breaks compilation of the linux 2.4.26 with the meesage: | |
| 3814 | − linux/include/net/tcp.h:945: error: statement expression in global scope */ | |
| 3813 | + /* this check breaks compilation of the linux 2.4.26 with the meesage: | |
| 3814 | + linux/include/net/tcp.h:945: error: statement expression in global scope */ | |
| 3815 | 3815 | |
| 3816 | 3816 | /* save all registers */ |
| 3817 | 3817 | save_regs(0); |
| @@ -3872,12 +3872,12 @@ ST_FUNC void unary(void) · 54 unmodified lines | ||
| 3872 | 3872 | if ((vtop->type.t & VT_BTYPE) == VT_PTR) |
| 3873 | 3873 | tcc_error("pointer not accepted for unary plus"); |
| 3874 | 3874 | /* In order to force cast, we add zero, except for floating point |
| 3875 | − where we really need an noop (otherwise -0.0 will be transformed | |
| 3876 | − into +0.0). */ | |
| 3877 | − if (!is_float(vtop->type.t)) { | |
| 3878 | − vpushi(0); | |
| 3879 | − gen_op('+'); | |
| 3880 | − } | |
| 3875 | + where we really need an noop (otherwise -0.0 will be transformed | |
| 3876 | + into +0.0). */ | |
| 3877 | + if (!is_float(vtop->type.t)) { | |
| 3878 | + vpushi(0); | |
| 3879 | + gen_op('+'); | |
| 3880 | + } | |
| 3881 | 3881 | break; |
| 3882 | 3882 | case TOK_SIZEOF: |
| 3883 | 3883 | case TOK_ALIGNOF1: |
| @@ -4050,20 +4050,20 @@ ST_FUNC void unary(void) · 166 unmodified lines | ||
| 4050 | 4050 | next(); |
| 4051 | 4051 | unary(); |
| 4052 | 4052 | t = vtop->type.t & VT_BTYPE; |
| 4053 | − if (is_float(t)) { | |
| 4053 | + if (is_float(t)) { | |
| 4054 | 4054 | /* In IEEE negate(x) isn't subtract(0,x), but rather |
| 4055 | − subtract(-0, x). */ | |
| 4056 | − vpush(&vtop->type); | |
| 4057 | − if (t == VT_FLOAT) | |
| 4058 | − vtop->c.f = -0.0f; | |
| 4059 | − else if (t == VT_DOUBLE) | |
| 4060 | − vtop->c.d = -0.0; | |
| 4061 | − else | |
| 4062 | − vtop->c.ld = -0.0; | |
| 4063 | − } else | |
| 4064 | − vpushi(0); | |
| 4065 | − vswap(); | |
| 4066 | − gen_op('-'); | |
| 4055 | + subtract(-0, x). */ | |
| 4056 | + vpush(&vtop->type); | |
| 4057 | + if (t == VT_FLOAT) | |
| 4058 | + vtop->c.f = -0.0f; | |
| 4059 | + else if (t == VT_DOUBLE) | |
| 4060 | + vtop->c.d = -0.0; | |
| 4061 | + else | |
| 4062 | + vtop->c.ld = -0.0; | |
| 4063 | + } else | |
| 4064 | + vpushi(0); | |
| 4065 | + vswap(); | |
| 4066 | + gen_op('-'); | |
| 4067 | 4067 | break; |
| 4068 | 4068 | case TOK_LAND: |
| 4069 | 4069 | if (!gnu_ext) |
| @@ -4142,7 +4142,7 @@ ST_FUNC void unary(void) · 72 unmodified lines | ||
| 4142 | 4142 | /* if forward reference, we must point to s */ |
| 4143 | 4143 | if (vtop->r & VT_SYM) { |
| 4144 | 4144 | vtop->sym = s; |
| 4145 | − vtop->c.ptr_offset = 0; | |
| 4145 | + vtop->c.ptr_offset = 0; | |
| 4146 | 4146 | } |
| 4147 | 4147 | break; |
| 4148 | 4148 | } |
| @@ -4312,10 +4312,10 @@ ST_FUNC void unary(void) · 163 unmodified lines | ||
| 4312 | 4312 | |
| 4313 | 4313 | |
| 4314 | 4314 | size = type_size(&s->type, &align); |
| 4315 | − /* We're writing whole regs often, make sure there's enough | |
| 4316 | − space. Assume register size is power of 2. */ | |
| 4317 | − if (regsize > align) | |
| 4318 | − align = regsize; | |
| 4315 | + /* We're writing whole regs often, make sure there's enough | |
| 4316 | + space. Assume register size is power of 2. */ | |
| 4317 | + if (regsize > align) | |
| 4318 | + align = regsize; | |
| 4319 | 4319 | loc = (loc - size) & -align; |
| 4320 | 4320 | addr = loc; |
| 4321 | 4321 | #if defined(TCC_TARGET_X86_64) && !defined(TCC_TARGET_PE) |
| @@ -4610,16 +4610,16 @@ static void expr_cond(void) · 288 unmodified lines | ||
| 4610 | 4610 | (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_LLONG | VT_UNSIGNED)) |
| 4611 | 4611 | type.t |= VT_UNSIGNED; |
| 4612 | 4612 | } else if (bt1 == VT_PTR || bt2 == VT_PTR) { |
| 4613 | − /* If one is a null ptr constant the result type | |
| 4614 | − is the other. */ | |
| 4615 | − if (is_null_pointer (vtop)) | |
| 4616 | − type = type1; | |
| 4617 | − else if (is_null_pointer (&sv)) | |
| 4618 | − type = type2; | |
| 4613 | + /* If one is a null ptr constant the result type | |
| 4614 | + is the other. */ | |
| 4615 | + if (is_null_pointer (vtop)) | |
| 4616 | + type = type1; | |
| 4617 | + else if (is_null_pointer (&sv)) | |
| 4618 | + type = type2; | |
| 4619 | 4619 | /* XXX: test pointer compatibility, C99 has more elaborate |
| 4620 | − rules here. */ | |
| 4621 | − else | |
| 4622 | − type = type1; | |
| 4620 | + rules here. */ | |
| 4621 | + else | |
| 4622 | + type = type1; | |
| 4623 | 4623 | } else if (bt1 == VT_FUNC || bt2 == VT_FUNC) { |
| 4624 | 4624 | /* XXX: test function pointer compatibility */ |
| 4625 | 4625 | type = bt1 == VT_FUNC ? type1 : type2; |
| @@ -4785,14 +4785,14 @@ static void label_or_decl(int l) · 159 unmodified lines | ||
| 4785 | 4785 | /* fast test first */ |
| 4786 | 4786 | if (tok >= TOK_UIDENT) |
| 4787 | 4787 | { |
| 4788 | − /* no need to save tokc because tok is an identifier */ | |
| 4789 | − last_tok = tok; | |
| 4790 | − next(); | |
| 4791 | − if (tok == ':') { | |
| 4792 | − unget_tok(last_tok); | |
| 4793 | − return; | |
| 4794 | − } | |
| 4795 | − unget_tok(last_tok); | |
| 4788 | + /* no need to save tokc because tok is an identifier */ | |
| 4789 | + last_tok = tok; | |
| 4790 | + next(); | |
| 4791 | + if (tok == ':') { | |
| 4792 | + unget_tok(last_tok); | |
| 4793 | + return; | |
| 4794 | + } | |
| 4795 | + unget_tok(last_tok); | |
| 4796 | 4796 | } |
| 4797 | 4797 | decl(l); |
| 4798 | 4798 | } |
| @@ -4891,10 +4891,10 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 92 unmodified lines | ||
| 4891 | 4891 | Sym *p; |
| 4892 | 4892 | switch(vtop->type.t & VT_BTYPE) { |
| 4893 | 4893 | /* case VT_PTR: */ |
| 4894 | − /* this breaks a compilation of the linux kernel v2.4.26 */ | |
| 4895 | − /* pmd_t *new = ({ __asm__ __volatile__("ud2\n") ; ((pmd_t *)1); }); */ | |
| 4896 | − /* Look a commit a80acab: Display error on statement expressions with complex return type */ | |
| 4897 | − /* A pointer is not a complex return type */ | |
| 4894 | + /* this breaks a compilation of the linux kernel v2.4.26 */ | |
| 4895 | + /* pmd_t *new = ({ __asm__ __volatile__("ud2\n") ; ((pmd_t *)1); }); */ | |
| 4896 | + /* Look a commit a80acab: Display error on statement expressions with complex return type */ | |
| 4897 | + /* A pointer is not a complex return type */ | |
| 4898 | 4898 | case VT_STRUCT: |
| 4899 | 4899 | case VT_ENUM: |
| 4900 | 4900 | case VT_FUNC: |
| @@ -5642,38 +5642,38 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 741 unmodified lines | ||
| 5642 | 5642 | AttributeDef ad1; |
| 5643 | 5643 | CType type1; |
| 5644 | 5644 | next(); |
| 5645 | − if (tcc_state->old_struct_init_code) { | |
| 5646 | − /* an old version of struct initialization. | |
| 5647 | − It have a problems. But with a new version | |
| 5648 | − linux 2.4.26 can't load ramdisk. | |
| 5649 | − */ | |
| 5650 | − while (tok == '(') { | |
| 5651 | − par_count++; | |
| 5652 | − next(); | |
| 5653 | − } | |
| 5654 | − if (!parse_btype(&type1, &ad1)) | |
| 5655 | − expect("cast"); | |
| 5656 | − type_decl(&type1, &ad1, &n, TYPE_ABSTRACT); | |
| 5657 | − #if 0 | |
| 5658 | − if (!is_assignable_types(type, &type1)) | |
| 5659 | − tcc_error("invalid type for cast"); | |
| 5660 | − #endif | |
| 5661 | − skip(')'); | |
| 5662 | − } | |
| 5663 | − else | |
| 5664 | − { | |
| 5645 | + if (tcc_state->old_struct_init_code) { | |
| 5646 | + /* an old version of struct initialization. | |
| 5647 | + It have a problems. But with a new version | |
| 5648 | + linux 2.4.26 can't load ramdisk. | |
| 5649 | + */ | |
| 5650 | + while (tok == '(') { | |
| 5651 | + par_count++; | |
| 5652 | + next(); | |
| 5653 | + } | |
| 5654 | + if (!parse_btype(&type1, &ad1)) | |
| 5655 | + expect("cast"); | |
| 5656 | + type_decl(&type1, &ad1, &n, TYPE_ABSTRACT); | |
| 5657 | + #if 0 | |
| 5658 | + if (!is_assignable_types(type, &type1)) | |
| 5659 | + tcc_error("invalid type for cast"); | |
| 5660 | + #endif | |
| 5661 | + skip(')'); | |
| 5662 | + } | |
| 5663 | + else | |
| 5664 | + { | |
| 5665 | 5665 | if (tok != '(') { |
| 5666 | − if (!parse_btype(&type1, &ad1)) | |
| 5667 | − expect("cast"); | |
| 5668 | − type_decl(&type1, &ad1, &n, TYPE_ABSTRACT); | |
| 5669 | − #if 0 | |
| 5670 | − if (!is_assignable_types(type, &type1)) | |
| 5671 | − tcc_error("invalid type for cast"); | |
| 5672 | − #endif | |
| 5673 | − skip(')'); | |
| 5674 | − } else | |
| 5675 | − unget_tok(tok); | |
| 5676 | − } | |
| 5666 | + if (!parse_btype(&type1, &ad1)) | |
| 5667 | + expect("cast"); | |
| 5668 | + type_decl(&type1, &ad1, &n, TYPE_ABSTRACT); | |
| 5669 | + #if 0 | |
| 5670 | + if (!is_assignable_types(type, &type1)) | |
| 5671 | + tcc_error("invalid type for cast"); | |
| 5672 | + #endif | |
| 5673 | + skip(')'); | |
| 5674 | + } else | |
| 5675 | + unget_tok(tok); | |
| 5676 | + } | |
| 5677 | 5677 | } |
| 5678 | 5678 | |
| 5679 | 5679 | no_oblock = 1; |
| @@ -5699,28 +5699,28 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 19 unmodified lines | ||
| 5699 | 5699 | |
| 5700 | 5700 | /* gr: skip fields from same union - ugly. */ |
| 5701 | 5701 | while (f->next) { |
| 5702 | − int align = 0; | |
| 5703 | − int f_size = type_size(&f->type, &align); | |
| 5704 | − int f_type = (f->type.t & VT_BTYPE); | |
| 5702 | + int align = 0; | |
| 5703 | + int f_size = type_size(&f->type, &align); | |
| 5704 | + int f_type = (f->type.t & VT_BTYPE); | |
| 5705 | 5705 | |
| 5706 | 5706 | ///printf("index: %2d %08x -- %2d %08x\n", f->c, f->type.t, f->next->c, f->next->type.t); |
| 5707 | 5707 | /* test for same offset */ |
| 5708 | 5708 | if (f->next->c != f->c) |
| 5709 | 5709 | break; |
| 5710 | 5710 | if ((f_type == VT_STRUCT) && (f_size == 0)) { |
| 5711 | − /* | |
| 5712 | − Lets assume a structure of size 0 can't be a member of the union. | |
| 5713 | − This allow to compile the following code from a linux kernel v2.4.26 | |
| 5714 | − typedef struct { } rwlock_t; | |
| 5715 | − struct fs_struct { | |
| 5716 | − int count; | |
| 5717 | − rwlock_t lock; | |
| 5718 | − int umask; | |
| 5719 | − }; | |
| 5720 | − struct fs_struct init_fs = { { (1) }, (rwlock_t) {}, 0022, }; | |
| 5721 | − tcc-0.9.23 can succesfully compile this version of the kernel. | |
| 5722 | − gcc don't have problems with this code too. | |
| 5723 | − */ | |
| 5711 | + /* | |
| 5712 | + Lets assume a structure of size 0 can't be a member of the union. | |
| 5713 | + This allow to compile the following code from a linux kernel v2.4.26 | |
| 5714 | + typedef struct { } rwlock_t; | |
| 5715 | + struct fs_struct { | |
| 5716 | + int count; | |
| 5717 | + rwlock_t lock; | |
| 5718 | + int umask; | |
| 5719 | + }; | |
| 5720 | + struct fs_struct init_fs = { { (1) }, (rwlock_t) {}, 0022, }; | |
| 5721 | + tcc-0.9.23 can succesfully compile this version of the kernel. | |
| 5722 | + gcc don't have problems with this code too. | |
| 5723 | + */ | |
| 5724 | 5724 | break; |
| 5725 | 5725 | } |
| 5726 | 5726 | /* if yes, test for bitfield shift */ |
| @@ -5760,21 +5760,21 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 33 unmodified lines | ||
| 5760 | 5760 | /* just skip expression */ |
| 5761 | 5761 | parlevel = parlevel1 = 0; |
| 5762 | 5762 | while ((parlevel > 0 || parlevel1 > 0 || |
| 5763 | − (tok != '}' && tok != ',')) && tok != -1) { | |
| 5763 | + (tok != '}' && tok != ',')) && tok != -1) { | |
| 5764 | 5764 | if (tok == '(') |
| 5765 | 5765 | parlevel++; |
| 5766 | 5766 | else if (tok == ')') { |
| 5767 | − if (parlevel == 0 && parlevel1 == 0) | |
| 5768 | − break; | |
| 5767 | + if (parlevel == 0 && parlevel1 == 0) | |
| 5768 | + break; | |
| 5769 | 5769 | parlevel--; |
| 5770 | 5770 | } |
| 5771 | − else if (tok == '{') | |
| 5772 | − parlevel1++; | |
| 5773 | − else if (tok == '}') { | |
| 5774 | − if (parlevel == 0 && parlevel1 == 0) | |
| 5775 | − break; | |
| 5776 | − parlevel1--; | |
| 5777 | − } | |
| 5771 | + else if (tok == '{') | |
| 5772 | + parlevel1++; | |
| 5773 | + else if (tok == '}') { | |
| 5774 | + if (parlevel == 0 && parlevel1 == 0) | |
| 5775 | + break; | |
| 5776 | + parlevel1--; | |
| 5777 | + } | |
| 5778 | 5778 | next(); |
| 5779 | 5779 | } |
| 5780 | 5780 | } else { |
| @@ -5995,12 +5995,12 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 214 unmodified lines | ||
| 5995 | 5995 | } else { |
| 5996 | 5996 | /* push global reference */ |
| 5997 | 5997 | sym = get_sym_ref(type, sec, addr, size); |
| 5998 | − vpushsym(type, sym); | |
| 5998 | + vpushsym(type, sym); | |
| 5999 | 5999 | } |
| 6000 | 6000 | /* patch symbol weakness */ |
| 6001 | 6001 | if (type->t & VT_WEAK) |
| 6002 | 6002 | weaken_symbol(sym); |
| 6003 | − apply_visibility(sym, type); | |
| 6003 | + apply_visibility(sym, type); | |
| 6004 | 6004 | #ifdef CONFIG_TCC_BCHECK |
| 6005 | 6005 | /* handles bounds now because the symbol must be defined |
| 6006 | 6006 | before for the relocation */ |
| @@ -6236,11 +6236,11 @@ static int decl0(int l, int is_for_loop_init) · 229 unmodified lines | ||
| 6236 | 6236 | if (((btype.t & VT_BTYPE) == VT_ENUM || |
| 6237 | 6237 | (btype.t & VT_BTYPE) == VT_STRUCT) && |
| 6238 | 6238 | tok == ';') { |
| 6239 | − if ((btype.t & VT_BTYPE) == VT_STRUCT) { | |
| 6240 | − int v = btype.ref->v; | |
| 6241 | − if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) >= SYM_FIRST_ANOM) | |
| 6242 | − tcc_warning("unnamed struct/union that defines no instances"); | |
| 6243 | − } | |
| 6239 | + if ((btype.t & VT_BTYPE) == VT_STRUCT) { | |
| 6240 | + int v = btype.ref->v; | |
| 6241 | + if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) >= SYM_FIRST_ANOM) | |
| 6242 | + tcc_warning("unnamed struct/union that defines no instances"); | |
| 6243 | + } | |
| 6244 | 6244 | next(); |
| 6245 | 6245 | continue; |
| 6246 | 6246 | } |
| @@ -6286,7 +6286,7 @@ static int decl0(int l, int is_for_loop_init) · 39 unmodified lines | ||
| 6286 | 6286 | if (ad.a.func_export) |
| 6287 | 6287 | type.t |= VT_EXPORT; |
| 6288 | 6288 | #endif |
| 6289 | − type.t |= ad.a.visibility << VT_VIS_SHIFT; | |
| 6289 | + type.t |= ad.a.visibility << VT_VIS_SHIFT; | |
| 6290 | 6290 | |
| 6291 | 6291 | if (tok == '{') { |
| 6292 | 6292 | if (l == VT_LOCAL) |
| @@ -6327,10 +6327,10 @@ static int decl0(int l, int is_for_loop_init) · 34 unmodified lines | ||
| 6327 | 6327 | if (sym->type.t & VT_STATIC) |
| 6328 | 6328 | type.t = (type.t & ~VT_EXTERN) | VT_STATIC; |
| 6329 | 6329 | |
| 6330 | − /* If the definition has no visibility use the | |
| 6331 | − one from prototype. */ | |
| 6332 | − if (! (type.t & VT_VIS_MASK)) | |
| 6333 | − type.t |= sym->type.t & VT_VIS_MASK; | |
| 6330 | + /* If the definition has no visibility use the | |
| 6331 | + one from prototype. */ | |
| 6332 | + if (! (type.t & VT_VIS_MASK)) | |
| 6333 | + type.t |= sym->type.t & VT_VIS_MASK; | |
| 6334 | 6334 | |
| 6335 | 6335 | if (!is_compatible_types(&sym->type, &type)) { |
| 6336 | 6336 | func_error1: |