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

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