[committed,2/2] libstdc++: Fix test that fails for C++98

Message ID 20200731190413.GZ3400@redhat.com
State New
Headers show
Series
  • [committed,1/2] libstdc++: Fix tests that fail for C++98
Related show

Commit Message

Bill Schmidt via Gcc-patches July 31, 2020, 7:04 p.m.
Local classes have no linkage so cannot be used as template arguments in
C++98.

libstdc++-v3/ChangeLog:

         * testsuite/20_util/specialized_algorithms/uninitialized_fill_n/sizes.cc:
         Move struct to namespace scope.


Tested powerpc64le-linux, committed to trunk.

Patch

commit f07fa7a31c89811ad9ffdd9831177cc815f098d2
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jul 31 19:58:03 2020

    libstdc++: Fix test that fails for C++98
    
    Local classes have no linkage so cannot be used as template arguments in
    C++98.
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/20_util/specialized_algorithms/uninitialized_fill_n/sizes.cc:
            Move struct to namespace scope.

diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/sizes.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/sizes.cc
index eb957e148da..f6e7a83c58d 100644
--- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/sizes.cc
+++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/sizes.cc
@@ -31,19 +31,19 @@  test01()
   VERIFY( i[3] == 0 );
 }
 
+// The standard only requires that n>0 and --n are valid expressions.
+struct Size
+{
+  int value;
+
+  void operator--() { --value; }
+
+  int operator>(void*) { return value != 0; }
+};
+
 void
 test02()
 {
-  // The standard only requires that n>0 and --n are valid expressions.
-  struct Size
-  {
-    int value;
-
-    void operator--() { --value; }
-
-    int operator>(void*) { return value != 0; }
-  };
-
   int i[5] = { };
   Size n = {4};
   std::uninitialized_fill_n(i, n, 0xdcba);