On Tue, Nov 11, 2014 at 9:09 AM, Uros Bizjak <ubiz...@gmail.com> wrote:
> On Mon, Nov 10, 2014 at 10:51 PM, Marc Glisse <marc.gli...@inria.fr> wrote:
>> On Mon, 10 Nov 2014, Richard Biener wrote:
>>
>>> No extra includes required?
>>
>>
>> <utility> is already included in wide-int.h and rtl.h, should probably move
>> those.
>
> Bah, we hit a problem. std::swap has been moved from <algorithm> to
> <utility> in C++11, and the patch breaks build on CentOS 5.11
> (gcc-4.1.2).
>
> Short of reverting the i386.c patch, is there a quick solution by
> including some additional headers?

Attached patch that implements both suggestions from Richi and Marc
fixes the bootstrap.

2014-11-11  Uros Bizjak  <ubiz...@gmail.com>

    * system.h: Include algorithm and utility.
    * rtl.h: Do not include utility here.
    * wide-int.h: Ditto.
    * tree-vect-data-refs.c (swap): Remove template.
    (vect_prune_runtime_alias_test_list): Use std::swap instead of swap.

Bootstrapped on x86_64-linux-gnu (CentOS 5.11).

OK for mainline?

BTW: There are lots of places where std::swap can be used, a nice
search-and-replace task for someone to start with gcc development. ;)

Uros.
Index: tree-vect-data-refs.c
===================================================================
--- tree-vect-data-refs.c       (revision 217340)
+++ tree-vect-data-refs.c       (working copy)
@@ -2718,14 +2718,6 @@
   return 0;
 }
 
-template <class T> static void
-swap (T& a, T& b)
-{
-  T c (a);
-  a = b;
-  b = c;
-}
-
 /* Function vect_vfa_segment_size.
 
    Create an expression that computes the size of segment
@@ -2858,7 +2850,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info
           dr_with_seg_len (dr_b, segment_length_b));
 
       if (compare_tree (DR_BASE_ADDRESS (dr_a), DR_BASE_ADDRESS (dr_b)) > 0)
-       swap (dr_with_seg_len_pair.first, dr_with_seg_len_pair.second);
+       std::swap (dr_with_seg_len_pair.first, dr_with_seg_len_pair.second);
 
       comp_alias_ddrs.safe_push (dr_with_seg_len_pair);
     }
@@ -2908,8 +2900,8 @@ vect_prune_runtime_alias_test_list (loop_vec_info
             and DR_A1 and DR_A2 are two consecutive memrefs.  */
          if (*dr_a1 == *dr_a2)
            {
-             swap (dr_a1, dr_b1);
-             swap (dr_a2, dr_b2);
+             std::swap (dr_a1, dr_b1);
+             std::swap (dr_a2, dr_b2);
            }
 
          if (!operand_equal_p (DR_BASE_ADDRESS (dr_a1->dr),
Index: wide-int.h
===================================================================
--- wide-int.h  (revision 217340)
+++ wide-int.h  (working copy)
@@ -216,8 +216,6 @@
    the same result as X + X; the precision of the shift amount Y
    can be arbitrarily different from X.  */
 
-
-#include <utility>
 #include "system.h"
 #include "hwint.h"
 #include "signop.h"
Index: rtl.h
===================================================================
--- rtl.h       (revision 217340)
+++ rtl.h       (working copy)
@@ -20,7 +20,6 @@
 #ifndef GCC_RTL_H
 #define GCC_RTL_H
 
-#include <utility>
 #include "statistics.h"
 #include "machmode.h"
 #include "input.h"
Index: system.h
===================================================================
--- system.h    (revision 217340)
+++ system.h    (working copy)
@@ -208,7 +208,9 @@
 #endif
 
 #ifdef __cplusplus
+# include <algorithm>
 # include <cstring>
+# include <utility>
 #endif
 
 /* Some of glibc's string inlines cause warnings.  Plus we'd rather

Reply via email to