From 9075a853dc919e2d028b4cf67af61183555dad13 Mon Sep 17 00:00:00 2001 From: acqn Date: Wed, 29 Jul 2020 15:09:53 +0800 Subject: [PATCH] Allows one trailing comma before the closing curly of a struct/union initializer. --- src/cc65/declare.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cc65/declare.c b/src/cc65/declare.c index a1d23c20b..0c489dab4 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -2230,6 +2230,13 @@ static unsigned ParseStructInit (Type* T, int* Braces, int AllowFlexibleMembers) /* Check for excess elements */ if (Entry == 0) { + /* Is there just one trailing comma before a closing curly? */ + if (NextTok.Tok == TOK_RCURLY && CurTok.Tok == TOK_COMMA) { + /* Skip comma and exit scope */ + NextToken (); + break; + } + if (HasCurly) { Error ("Excess elements in %s initializer", GetBasicTypeName (T)); SkipInitializer (HasCurly);