History

Clean up lots of rogue tabs.

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.

gus knight committed 11 years ago

Commit d6b64e21 parent 410312210 files · +427 −428Browse files

Showing the changes to tccgen.c (1 of 10 files). Show all

Unified · Split

tccgen.c+169−169
@@ -323,7 +323,7 @@ static void apply_visibility(Sym *sym, CType *type) · 322 unmodified lines
323323 ElfW(Sym) *esym;
324324
325325 esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];
326− vis >>= VT_VIS_SHIFT;
326+ vis >>= VT_VIS_SHIFT;
327327 esym->st_other = (esym->st_other & ~ELFW(ST_VISIBILITY)(-1)) | vis;
328328 }
329329 }
@@ -1631,7 +1631,7 @@ static inline int is_null_pointer(SValue *p) · 1301 unmodified lines
16311631 return 0;
16321632 return ((p->type.t & VT_BTYPE) == VT_INT && p->c.i == 0) ||
16331633 ((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);
16351635 }
16361636
16371637 static inline int is_integer_btype(int bt)
@@ -1761,18 +1761,18 @@ ST_FUNC void gen_op(int op) · 123 unmodified lines
17611761 #if 0
17621762 /* #ifdef CONFIG_TCC_BCHECK
17631763 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+ }
17731773 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
17761776 */
17771777 /* if evaluating constant expression, no code should be
17781778 generated, so no bound check */
@@ -2450,18 +2450,18 @@ static void gen_assign_cast(CType *dt) · 671 unmodified lines
24502450 dbt = dt->t & VT_BTYPE;
24512451 sbt = st->t & VT_BTYPE;
24522452 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");
24652465 }
24662466 if (dt->t & VT_CONSTANT)
24672467 tcc_warning("assignment of read-only location");
@@ -2542,7 +2542,7 @@ ST_FUNC void vstore(void) · 74 unmodified lines
25422542 dbt = ft & VT_BTYPE;
25432543 if ((((sbt == VT_INT || sbt == VT_SHORT) && dbt == VT_BYTE) ||
25442544 (sbt == VT_INT && dbt == VT_SHORT))
2545− && !(vtop->type.t & VT_BITFIELD)) {
2545+ && !(vtop->type.t & VT_BITFIELD)) {
25462546 /* optimize char/short casts */
25472547 delayed_cast = VT_MUSTCAST;
25482548 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
27642764 next();
27652765 skip(')');
27662766 break;
2767− case TOK_VISIBILITY1:
2768− case TOK_VISIBILITY2:
2767+ case TOK_VISIBILITY1:
2768+ case TOK_VISIBILITY2:
27692769 skip('(');
27702770 if (tok != TOK_STR)
27712771 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
27812781 expect("visibility(\"default|hidden|internal|protected\")");
27822782 next();
27832783 skip(')');
@@ -2973,8 +2973,8 @@ static void struct_decl(CType *type, int u, int tdef) · 189 unmodified lines
29732973 while (tok != '}') {
29742974 parse_btype(&btype, &ad);
29752975 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",
29782978 get_tok_str(v, NULL));
29792979 bit_size = -1;
29802980 v = 0;
@@ -2982,21 +2982,21 @@ static void struct_decl(CType *type, int u, int tdef) · 1 unmodified line
29822982 if (tok != ':') {
29832983 type_decl(&type1, &ad, &v, TYPE_DIRECT | TYPE_ABSTRACT);
29842984 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+ }
29942994 }
29952995 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",
30003000 get_tok_str(v, NULL));
30013001 }
30023002 if ((type1.t & VT_BTYPE) == VT_FUNC ||
@@ -3807,11 +3807,11 @@ ST_FUNC void unary(void) · 804 unmodified lines
38073807 gen_cast(&type);
38083808 }
38093809 } else if (tok == '{') {
3810− /*
3810+ /*
38113811 if (nocode_wanted)
38123812 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 */
38153815
38163816 /* save all registers */
38173817 save_regs(0);
@@ -3872,12 +3872,12 @@ ST_FUNC void unary(void) · 54 unmodified lines
38723872 if ((vtop->type.t & VT_BTYPE) == VT_PTR)
38733873 tcc_error("pointer not accepted for unary plus");
38743874 /* 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+ }
38813881 break;
38823882 case TOK_SIZEOF:
38833883 case TOK_ALIGNOF1:
@@ -4050,20 +4050,20 @@ ST_FUNC void unary(void) · 166 unmodified lines
40504050 next();
40514051 unary();
40524052 t = vtop->type.t & VT_BTYPE;
4053− if (is_float(t)) {
4053+ if (is_float(t)) {
40544054 /* 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('-');
40674067 break;
40684068 case TOK_LAND:
40694069 if (!gnu_ext)
@@ -4142,7 +4142,7 @@ ST_FUNC void unary(void) · 72 unmodified lines
41424142 /* if forward reference, we must point to s */
41434143 if (vtop->r & VT_SYM) {
41444144 vtop->sym = s;
4145− vtop->c.ptr_offset = 0;
4145+ vtop->c.ptr_offset = 0;
41464146 }
41474147 break;
41484148 }
@@ -4312,10 +4312,10 @@ ST_FUNC void unary(void) · 163 unmodified lines
43124312
43134313
43144314 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;
43194319 loc = (loc - size) & -align;
43204320 addr = loc;
43214321 #if defined(TCC_TARGET_X86_64) && !defined(TCC_TARGET_PE)
@@ -4610,16 +4610,16 @@ static void expr_cond(void) · 288 unmodified lines
46104610 (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_LLONG | VT_UNSIGNED))
46114611 type.t |= VT_UNSIGNED;
46124612 } 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;
46194619 /* XXX: test pointer compatibility, C99 has more elaborate
4620− rules here. */
4621− else
4622− type = type1;
4620+ rules here. */
4621+ else
4622+ type = type1;
46234623 } else if (bt1 == VT_FUNC || bt2 == VT_FUNC) {
46244624 /* XXX: test function pointer compatibility */
46254625 type = bt1 == VT_FUNC ? type1 : type2;
@@ -4785,14 +4785,14 @@ static void label_or_decl(int l) · 159 unmodified lines
47854785 /* fast test first */
47864786 if (tok >= TOK_UIDENT)
47874787 {
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);
47964796 }
47974797 decl(l);
47984798 }
@@ -4891,10 +4891,10 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 92 unmodified lines
48914891 Sym *p;
48924892 switch(vtop->type.t & VT_BTYPE) {
48934893 /* 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 */
48984898 case VT_STRUCT:
48994899 case VT_ENUM:
49004900 case VT_FUNC:
@@ -5642,38 +5642,38 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 741 unmodified lines
56425642 AttributeDef ad1;
56435643 CType type1;
56445644 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+ {
56655665 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+ }
56775677 }
56785678
56795679 no_oblock = 1;
@@ -5699,28 +5699,28 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 19 unmodified lines
56995699
57005700 /* gr: skip fields from same union - ugly. */
57015701 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);
57055705
57065706 ///printf("index: %2d %08x -- %2d %08x\n", f->c, f->type.t, f->next->c, f->next->type.t);
57075707 /* test for same offset */
57085708 if (f->next->c != f->c)
57095709 break;
57105710 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+ */
57245724 break;
57255725 }
57265726 /* if yes, test for bitfield shift */
@@ -5760,21 +5760,21 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 33 unmodified lines
57605760 /* just skip expression */
57615761 parlevel = parlevel1 = 0;
57625762 while ((parlevel > 0 || parlevel1 > 0 ||
5763− (tok != '}' && tok != ',')) && tok != -1) {
5763+ (tok != '}' && tok != ',')) && tok != -1) {
57645764 if (tok == '(')
57655765 parlevel++;
57665766 else if (tok == ')') {
5767− if (parlevel == 0 && parlevel1 == 0)
5768− break;
5767+ if (parlevel == 0 && parlevel1 == 0)
5768+ break;
57695769 parlevel--;
57705770 }
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+ }
57785778 next();
57795779 }
57805780 } else {
@@ -5995,12 +5995,12 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 214 unmodified lines
59955995 } else {
59965996 /* push global reference */
59975997 sym = get_sym_ref(type, sec, addr, size);
5998− vpushsym(type, sym);
5998+ vpushsym(type, sym);
59995999 }
60006000 /* patch symbol weakness */
60016001 if (type->t & VT_WEAK)
60026002 weaken_symbol(sym);
6003− apply_visibility(sym, type);
6003+ apply_visibility(sym, type);
60046004 #ifdef CONFIG_TCC_BCHECK
60056005 /* handles bounds now because the symbol must be defined
60066006 before for the relocation */
@@ -6236,11 +6236,11 @@ static int decl0(int l, int is_for_loop_init) · 229 unmodified lines
62366236 if (((btype.t & VT_BTYPE) == VT_ENUM ||
62376237 (btype.t & VT_BTYPE) == VT_STRUCT) &&
62386238 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+ }
62446244 next();
62456245 continue;
62466246 }
@@ -6286,7 +6286,7 @@ static int decl0(int l, int is_for_loop_init) · 39 unmodified lines
62866286 if (ad.a.func_export)
62876287 type.t |= VT_EXPORT;
62886288 #endif
6289− type.t |= ad.a.visibility << VT_VIS_SHIFT;
6289+ type.t |= ad.a.visibility << VT_VIS_SHIFT;
62906290
62916291 if (tok == '{') {
62926292 if (l == VT_LOCAL)
@@ -6327,10 +6327,10 @@ static int decl0(int l, int is_for_loop_init) · 34 unmodified lines
63276327 if (sym->type.t & VT_STATIC)
63286328 type.t = (type.t & ~VT_EXTERN) | VT_STATIC;
63296329
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;
63346334
63356335 if (!is_compatible_types(&sym->type, &type)) {
63366336 func_error1:

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