Blame SOURCES/bison-3.0.4-c++-test-failure.patch

6bcc56
commit 952416114729b95209dccfc4edacfc1ff13b4e82
6bcc56
Author: Akim Demaille <akim@lrde.epita.fr>
6bcc56
Date:   Mon Jan 26 18:23:12 2015 +0100
6bcc56
6bcc56
    tests: c++: fix symbol lookup issue
6bcc56
    
6bcc56
    Sun C 5.13 SunOS_sparc 2014/10/20 reports errors on tests 430-432.
6bcc56
    
6bcc56
    Reported by Dennis Clarke.
6bcc56
    <http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00087.html>
6bcc56
    
6bcc56
    * tests/c++.at (Variants): Be sure to emit operator<< before using it:
6bcc56
    use "%code top" rather than "%code".
6bcc56
    Prefer std::vector to std::list.
6bcc56
    Do not define anything in std::, to avoid undefined behavior.
6bcc56
6bcc56
diff --git a/tests/c++.at b/tests/c++.at
6bcc56
index 55d7d40..60292f4 100644
6bcc56
--- a/tests/c++.at
6bcc56
+++ b/tests/c++.at
6bcc56
@@ -96,7 +96,7 @@ AT_SETUP([C++ Variant-based Symbols])
6bcc56
 AT_KEYWORDS([variant])
6bcc56
 
6bcc56
 AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %debug $1])
6bcc56
-# Store strings and integers in a list of strings.
6bcc56
+# Store strings and integers in a vector of strings.
6bcc56
 AT_DATA_GRAMMAR([list.y],
6bcc56
 [[%skeleton "lalr1.cc"
6bcc56
 %define api.value.type variant
6bcc56
@@ -114,20 +114,20 @@ AT_DATA_GRAMMAR([list.y],
6bcc56
 }
6bcc56
 
6bcc56
 %token <int> INT "int"
6bcc56
-%type < std::list<int> > exp
6bcc56
+%type < std::vector<int> > exp
6bcc56
 
6bcc56
 %printer { yyo << $$; } <int>
6bcc56
 %printer
6bcc56
   {
6bcc56
-    for (std::list<int>::const_iterator i = $$.begin (); i != $$.end (); ++i)
6bcc56
+    for (std::vector<int>::const_iterator i = $$.begin (); i != $$.end (); ++i)
6bcc56
       {
6bcc56
         if (i != $$.begin ())
6bcc56
           yyo << ", ";
6bcc56
         yyo << *i;
6bcc56
       }
6bcc56
-  } < std::list<int> >
6bcc56
+  } < std::vector<int> >
6bcc56
 
6bcc56
-%code requires { #include <list> }
6bcc56
+%code requires { #include <vector> }
6bcc56
 %code { int yylex (yy::parser::semantic_type* yylval); }
6bcc56
 
6bcc56
 %%
6bcc56
@@ -185,7 +185,7 @@ m4_pushdef([AT_TEST],
6bcc56
 [AT_SETUP([Variants $1])
6bcc56
 
6bcc56
 AT_BISON_OPTION_PUSHDEFS([%debug $1])
6bcc56
-# Store strings and integers in a list of strings.
6bcc56
+# Store strings and integers in a vector of strings.
6bcc56
 AT_DATA_GRAMMAR([list.y],
6bcc56
 [[%debug
6bcc56
 %define api.value.type variant
6bcc56
@@ -194,29 +194,25 @@ AT_DATA_GRAMMAR([list.y],
6bcc56
 
6bcc56
 %code requires // code for the .hh file
6bcc56
 {
6bcc56
-#include <list>
6bcc56
+#include <vector>
6bcc56
 #include <string>
6bcc56
-typedef std::list<std::string> strings_type;
6bcc56
+typedef std::vector<std::string> strings_type;
6bcc56
 }
6bcc56
 
6bcc56
-%code // code for the .cc file
6bcc56
+%code top // code for the .cc file.
6bcc56
 {
6bcc56
 #include <cstdlib> // abort, getenv
6bcc56
 #include <iostream>
6bcc56
+#include <vector>
6bcc56
 #include <sstream>
6bcc56
+#include <string>
6bcc56
 
6bcc56
-  namespace yy
6bcc56
-  {
6bcc56
-    static]AT_TOKEN_CTOR_IF([[
6bcc56
-    parser::symbol_type yylex ()]], [[
6bcc56
-    parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
6bcc56
-                              parser::location_type* yylloc])[)]])[;
6bcc56
-  }
6bcc56
 
6bcc56
-  // Printing a list of strings (for %printer).
6bcc56
-  // Koening look up will look into std, since that's an std::list.
6bcc56
-  namespace std
6bcc56
+  typedef std::vector<std::string> strings_type;
6bcc56
+
6bcc56
+  namespace yy
6bcc56
   {
6bcc56
+    // Must be available early, as is used in %destructor.
6bcc56
     std::ostream&
6bcc56
     operator<<(std::ostream& o, const strings_type& s)
6bcc56
     {
6bcc56
@@ -230,16 +226,27 @@ typedef std::list<std::string> strings_type;
6bcc56
       return o << ')';
6bcc56
     }
6bcc56
   }
6bcc56
+}
6bcc56
 
6bcc56
-  // Conversion to string.
6bcc56
-  template <typename T>
6bcc56
-    inline
6bcc56
-    std::string
6bcc56
-    to_string (const T& t)
6bcc56
+%code // code for the .cc file.
6bcc56
+{
6bcc56
+  namespace yy
6bcc56
   {
6bcc56
-    std::ostringstream o;
6bcc56
-    o << t;
6bcc56
-    return o.str ();
6bcc56
+    static]AT_TOKEN_CTOR_IF([[
6bcc56
+    parser::symbol_type yylex ()]], [[
6bcc56
+    parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
6bcc56
+                              parser::location_type* yylloc])[)]])[;
6bcc56
+
6bcc56
+    // Conversion to string.
6bcc56
+    template <typename T>
6bcc56
+      inline
6bcc56
+      std::string
6bcc56
+      to_string (const T& t)
6bcc56
+    {
6bcc56
+      std::ostringstream o;
6bcc56
+      o << t;
6bcc56
+      return o.str ();
6bcc56
+    }
6bcc56
   }
6bcc56
 }
6bcc56
 
6bcc56
@@ -252,10 +259,10 @@ typedef std::list<std::string> strings_type;
6bcc56
 // Using the template type to exercize its parsing.
6bcc56
 // Starting with :: to ensure we don't output "<::" which starts by the
6bcc56
 // digraph for the left square bracket.
6bcc56
-%type <::std::list<std::string>> list;
6bcc56
+%type <::std::vector<std::string>> list;
6bcc56
 
6bcc56
 %printer { yyo << $$; }
6bcc56
-  <int> <::std::string> <::std::list<std::string>>;
6bcc56
+  <int> <::std::string> <::std::vector<std::string>>;
6bcc56
 %destructor { std::cerr << "Destroy: " << $$ << '\n'; } <*>;
6bcc56
 %destructor { std::cerr << "Destroy: \"" << $$ << "\"\n"; } <::std::string>;
6bcc56
 %%