[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] 回复: tcc grammar problems
From: |
jiang |
Subject: |
[Tinycc-devel] 回复: tcc grammar problems |
Date: |
Sat, 09 Aug 2014 10:52:14 +0800 |
I recently some busy. may have to over a day or two to use the computer. I will
give you reply.
Best regards,
jiang
Thomas Preud'homme <address@hidden>编写:
>Le mercredi 06 août 2014, 22:41:18 Thomas Preud'homme a écrit :
>
>[SNIP review part 2]
>
>And here is the final part (part 3)
>
>@@ -3605,7 +3643,7 @@ static void vpush_tokc(int t)
>
>ST_FUNC void unary(void)
>{
>- int n, t, align, size, r, sizeof_caller;
>+ int n, t, align, size, r, sizeof_caller, save_ctrl;
> CType type;
> Sym *s;
> AttributeDef ad;
>@@ -3714,7 +3752,10 @@ ST_FUNC void unary(void)
> return;
> }
> unary();
>+ save_ctrl = gen_ctrl;
>+ gen_ctrl = CTRL_FOCE;
> gen_cast(&type);
>+ gen_ctrl = save_ctrl;
>
>
>I think it would be better to add a parameter "explicit" of type bool to
>gen_cast(). CTRL_INIT looks weird and you only need to know if it's an
>implicit cast or not.
>
>
> }
> } else if (tok == '{') {
> /* save all registers */
>@@ -5127,7 +5168,7 @@ static void decl_designator(CType *type, Section *sec,
>unsigned long c,
>static void init_putv(CType *type, Section *sec, unsigned long c,
> int v, int expr_type)
>{
>- int saved_global_expr, bt, bit_pos, bit_size;
>+ int saved_global_expr, bt, bit_pos, bit_size, save_ctrl;
> void *ptr;
> unsigned long long bit_mask;
> CType dtype;
>@@ -5147,7 +5188,10 @@ static void init_putv(CType *type, Section *sec,
>unsigned long c,
> tcc_error("initializer element is not constant");
> break;
> case EXPR_ANY:
>+ save_ctrl = gen_ctrl;
>+ gen_ctrl = CTRL_INIT;
> expr_eq();
>+ gen_ctrl = save_ctrl;
> break;
> }
>
>
>I don't see why this is needed. The code you moved in vstore() didn't need it
>before.
>
>
>diff --git a/tests/tests2/03_struct.c b/tests/tests2/03_struct.c
>index c5d48c5..e06d20d 100644
>--- a/tests/tests2/03_struct.c
>+++ b/tests/tests2/03_struct.c
>@@ -27,5 +27,36 @@ int main()
> printf("%d\n", jones[1].boris);
> printf("%d\n", jones[1].natasha);
>
>+ struct sbf1 {
>+ int f1 : 3;
>+ int : 2;
>+ int f2 : 1;
>+ int : 0;
>+ int f3 : 5;
>+ int f4 : 7;
>+ unsigned int f5 : 7;
>+ } st1;
>+ st1.f1 = st1.f2 = st1.f3 = st1.f4 = st1.f5 = 3;
>+ printf("%d %d %d %d %d\n",
>+ st1.f1, st1.f2, st1.f3, st1.f4, st1.f5);
>+
>+ struct { unsigned a:9, b:7, c:5; } s1;
>+ s1.a = s1.b = s1.c = 3;
>+ printf("%d / %d / %d\n", s1.a, s1.b, s1.c);
>+
>+ struct {
>+ unsigned a:9, b:5, c:7;
>+ } s2, *ps = &s2;
>+ int n = 250;
>+
>+ int ii = ps->a = ps->b = ps->c = n + 4;
>+ printf("%d / %d / %d\n", ps->a, ps->b, ps->c);
>+ printf("%d\n", ii);
>+
>+ ps->a = n + 4;
>+ ps->b = n + 4;
>+ ps->c = n + 4;
>+ printf("%d / %d / %d\n", ps->a, ps->b, ps->c);
>+
> return 0;
>}
>diff --git a/tests/tests2/03_struct.expect b/tests/tests2/03_struct.expect
>index ecbf589..6b90186 100644
>--- a/tests/tests2/03_struct.expect
>+++ b/tests/tests2/03_struct.expect
>@@ -1,6 +1,12 @@
>+03_struct.c:39: warning: overflow in implicit constant conversion
>12
>34
>12
>34
>56
>78
>+-1 -1 3 3 3
>+3 / 3 / 3
>+30 / 30 / 126
>+30
>+254 / 30 / 126
>
>
>The added code in 03_struct.c don't exercise the explicit cast. Is it exercise
>somewhere else? If not you should add something for this.
>
>Best regards,
>
>Thomas