From bbaf618c3e9a5645c5d71bf2ea0de2bdeb8a4976 Mon Sep 17 00:00:00 2001
From: Akim Demaille <akim@lrde.epita.fr>
Date: Sat, 24 Mar 2012 14:11:06 +0100
Subject: [PATCH 2/2] tests: beware of -pedantic on large #line numbers.

* tests/local.at (AT_TEST_TABLES_AND_PARSE): Don't pass -pedantic
when compiling large canonical-LR parsers.
Reported by Tys Lefering.
http://lists.gnu.org/archive/html/bug-bison/2012-03/msg00025.html
(cherry picked from commit 8ec3110a9ed4e4d26327bbccfc25278c374fd99a)
---
 tests/local.at |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tests/local.at b/tests/local.at
index 462301d..d651eb9 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -610,6 +610,17 @@ m4_if(m4_index(m4_quote($3), [last-state]), -1,
 
 $9
 
+# Canonical LR generates very large tables, resulting in very long
+# files with #line directives that may overflow what the standards
+# (C90 and C++98) guarantee: 32767.  In that case, GCC's -pedantic
+# will issue an error.
+#
+# There is no "" around `wc` since some indent the result.
+m4_bmatch([$4], [%define lr.type canonical-lr],
+[if test 32767 -lt `wc -l < input.c`; then
+  CFLAGS=`echo " $CFLAGS " | sed -e 's/ -pedantic //'`
+  CXXFLAGS=`echo " $CXXFLAGS " | sed -e 's/ -pedantic //'`
+fi])
 AT_COMPILE([[input]])
 
 AT_PARSER_CHECK([[./input]],
-- 
1.7.9.4

