commit ef1b413ce63057ad946e5dbb202006196e8d1510
parent f864f40c5ed0e7dd86dbb74ff81141d052806556
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('}');