commit a80c579064560b4bcf8ed28ed857b6265dc5fd37
parent 8e517c601fa233750a08f2ce8f8656557486d76a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 2 Nov 2021 08:36:25 +0100
cc1: Accept , at the end of initlist
A trailing comma is accepted at the end of a initializer.
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/cmd/cc/cc1/init.c b/src/cmd/cc/cc1/init.c
@@ -223,7 +223,7 @@ initlist(Type *tp)
if (accept('{'))
braces = 1;
- do {
+ for (;;) {
curtp = inttype;
switch (yytoken) {
case '[':
@@ -291,7 +291,11 @@ new_desig:
errorp("compound literal too big");
if (nelem == in.pos && !braces)
break;
- } while (accept(','));
+ if (!accept(','))
+ break;
+ if (yytoken == '}')
+ break;
+ }
if (braces)
expect('}');