scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 51d0b0427379342a3b2d3701c495bd87b3bea8b1
parent 45c82467f51b356445aae338b33968c9d4f08788
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 18 Sep 2015 10:15:06 +0200

Remove parentheses in struct definitions

They are totally unneeded because we can add the member to the last struct/union
defined.

Diffstat:
Mcc1/code.c | 3+--
Mcc1/ir.md | 10++--------
Mcc1/tests/test002.c | 2--
Mcc1/tests/test015.c | 8+-------
Mcc1/tests/test017.c | 4----
5 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/cc1/code.c b/cc1/code.c @@ -263,11 +263,10 @@ emittype(Type *tp) emitletter(tp); if ((tag = tp->tag->name) != NULL) printf("\t%s", tag); - puts("\n("); + putchar('\n'); n = tp->n.elem; for (sp = tp->p.fields; n-- > 0; ++sp) emit(ODECL, *sp); - puts(")"); break; case FTN: emitletter(tp); diff --git a/cc1/ir.md b/cc1/ir.md @@ -65,10 +65,8 @@ name, a type and the name of the variable: ### Type declarations ### Some declarations need a previous declaration of the types involved -in the variable declaration. In the case of structs and unions -a '(' means that begins a list of members of the last type declaration -(the front end must ensure that '(; only can follow struct/union -declarations). +in the variable declaration. In the case of members, they form part +of the last struct or union declared. For example the next code: @@ -80,10 +78,8 @@ For example the next code: will generate the next output: > S2 foo -> ( > M3 I i > M4 W c -> ) > G5 S2 var1 @@ -351,8 +347,6 @@ switch. * T -- local (function scopped static variable) * M -- member (struct/union member) * L -- label -* ( -- begin of struct/enum definition -* ) -- end of struct/enum definition * { -- end of function body * } -- end of fucntion body * - -- end of function parameters diff --git a/cc1/tests/test002.c b/cc1/tests/test002.c @@ -8,10 +8,8 @@ G7 F1 main { - S2 S -( M5 I i M6 P next -) A2 S2 y A3 P p A4 N n diff --git a/cc1/tests/test015.c b/cc1/tests/test015.c @@ -2,20 +2,14 @@ name: TEST015 description: Stress namespace mechanism output: -test015.c:58: error: label 's' already defined +test015.c:52: error: label 's' already defined S8 s2 -( M9 I s -) S5 s1 -( M6 I s M10 S8 s1 -) S2 s -( M11 S5 s -) G12 S2 s2 F1 G13 F1 main diff --git a/cc1/tests/test017.c b/cc1/tests/test017.c @@ -7,15 +7,11 @@ G9 F1 main { - S2 s1 -( M3 I y M4 I z -) A2 S2 nested S6 s2 -( M8 P p -) A3 S6 v A3 M8 .P A2 'P :P A3 M8 .P @S2 M3 .I #I1 :I