From b4e82c6f51e74ee63288e0369905dfcb71597e41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Sat, 13 Jun 2015 13:32:58 +0200
Subject: [PATCH] Parser.C: Improved diagnostics from group().

Don't drop the grouping stack on the floor if there are missing ungroupings.

Fixes loss of initial code in precompiler if braces are missing at
the end of classes.
---
 lib/modules/Parser.pmod/C.pmod | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/modules/Parser.pmod/C.pmod b/lib/modules/Parser.pmod/C.pmod
index a2a1c7267e..53ffb352ca 100644
--- a/lib/modules/Parser.pmod/C.pmod
+++ b/lib/modules/Parser.pmod/C.pmod
@@ -211,6 +211,15 @@ array(Token|array) group(array(string|Token) tokens,
 	ret=stack->pop()+({ ret + ({token}) });
     }
   }
+  while (sizeof(stack)) {
+    Token token = ret[0];
+    werror("%s:%d: Missing %O.\n",
+	   token->file||"-", token->line,
+	   groupings[(string)token]);
+    ret = stack->pop() +
+      ({ ret +
+	 ({ Token(groupings[(string)token], token->line, token->file) }) });
+  }
   return ret;
 }
 
-- 
GitLab