EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

This bug was originally fixed in http://reviews.llvm.org/D7201. 

However it was broken again by the fix to 
https://llvm.org/bugs/show_bug.cgi?id=22605.

This patch re-fixes __wrap_iter with GCC by providing a forward declaration of 
<vector> before the friend declaration in __wrap_iter.
This patch avoids the issues in PR22605 by putting canonical forward 
declarations in <iosfwd> and including <iosfwd> in <vector>.

<iosfwd> was chosen as the canonical forward declaration headers for the 
following reasons:

1. `<iosfwd>` is small with almost no dependancies.
2. It already forward declares `std::allocator`
3. It is already included in `<iterator>` which we need to fix the GCC bug.

This patch fixes the test "gcc_workaround.pass.cpp"

http://reviews.llvm.org/D16345

Files:
  include/iosfwd
  include/iterator
  include/vector

Index: include/vector
===================================================================
--- include/vector
+++ include/vector
@@ -262,6 +262,7 @@
 */
 
 #include <__config>
+#include <iosfwd> // for forward declaration of vector
 #include <__bit_reference>
 #include <type_traits>
 #include <climits>
@@ -453,7 +454,7 @@
     }
 }
 
-template <class _Tp, class _Allocator = allocator<_Tp> >
+template <class _Tp, class _Allocator /* = allocator<_Tp> */>
 class _LIBCPP_TYPE_VIS_ONLY vector
     : private __vector_base<_Tp, _Allocator>
 {
Index: include/iterator
===================================================================
--- include/iterator
+++ include/iterator
@@ -340,10 +340,10 @@
 */
 
 #include <__config>
+#include <iosfwd> // for forward declarations of vector and string.
 #include <__functional_base>
 #include <type_traits>
 #include <cstddef>
-#include <iosfwd>
 #include <initializer_list>
 #ifdef __APPLE__
 #include <Availability.h>
Index: include/iosfwd
===================================================================
--- include/iosfwd
+++ include/iosfwd
@@ -194,6 +194,11 @@
 typedef basic_string<char, char_traits<char>, allocator<char> > string;
 typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > 
wstring;
 
+
+// Include other forward declarations here
+template <class _Tp, class _Alloc = allocator<_Tp> >
+class _LIBCPP_TYPE_VIS_ONLY vector;
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_IOSFWD


Index: include/vector
===================================================================
--- include/vector
+++ include/vector
@@ -262,6 +262,7 @@
 */
 
 #include <__config>
+#include <iosfwd> // for forward declaration of vector
 #include <__bit_reference>
 #include <type_traits>
 #include <climits>
@@ -453,7 +454,7 @@
     }
 }
 
-template <class _Tp, class _Allocator = allocator<_Tp> >
+template <class _Tp, class _Allocator /* = allocator<_Tp> */>
 class _LIBCPP_TYPE_VIS_ONLY vector
     : private __vector_base<_Tp, _Allocator>
 {
Index: include/iterator
===================================================================
--- include/iterator
+++ include/iterator
@@ -340,10 +340,10 @@
 */
 
 #include <__config>
+#include <iosfwd> // for forward declarations of vector and string.
 #include <__functional_base>
 #include <type_traits>
 #include <cstddef>
-#include <iosfwd>
 #include <initializer_list>
 #ifdef __APPLE__
 #include <Availability.h>
Index: include/iosfwd
===================================================================
--- include/iosfwd
+++ include/iosfwd
@@ -194,6 +194,11 @@
 typedef basic_string<char, char_traits<char>, allocator<char> > string;
 typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
 
+
+// Include other forward declarations here
+template <class _Tp, class _Alloc = allocator<_Tp> >
+class _LIBCPP_TYPE_VIS_ONLY vector;
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_IOSFWD
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to