commit 8d33f673d3aaa7107c8e86d6591bd3f077f0313d
Author: Raphael Kubo da Costa <rakuco@FreeBSD.org>
Date:   Fri May 10 04:08:38 2013 +0300

    Special-case the forward declaration of STL types for libc++.
    
    This is somewhat of a follow-up to 5210d47aa66214e3cb16f394d0510a91f770c1b1.
    libc++ declares the STL types in an inline namespace within the "std" one if
    clang is used.
    
    If one includes a header such as <iterator> before a Qt one and builds with
    QT_NO_STL, the following ends up happening:
    
      // <iterator>
      namespace std {
          inline namespace __1 {
              struct random_access_iterator ... ;
          }
      }
    
      // qiterator.h
      #ifdef QT_NO_STL
      namespace std {
         struct random_access_iterator;
      }
      #endif
    
    qiterator.h's declaration shadows the original one, and the compiler
    complains random_access_iterator lacks an actual declaration.
    
    Solve this by checking for libc++ and forward-declaring the iterator types
    we need within the same inline namespace.
    
    Not backported from qtbase because QT_NO_STL does not exist in Qt 5.
    
    Change-Id: I6742d540f6538a30aa060a4447c288cfb9cd781d
    Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>

diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h
index c859d37..54c331e 100644
--- a/src/corelib/tools/qiterator.h
+++ b/src/corelib/tools/qiterator.h
@@ -47,10 +47,33 @@
 QT_BEGIN_HEADER
 
 #ifdef QT_NO_STL
+# include <ciso646> // No-op, indirectly include additional configuration headers.
+# if defined(_LIBCPP_VERSION)
+// libc++ may declare these structs in an inline namespace. Forward-declare
+// these iterators in the same namespace so that we do not shadow the original
+// declarations.
+
+// Tell clang not to warn about the use of inline namespaces when not building
+// in C++11 mode.
+#  if defined(Q_CC_CLANG)
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wc++11-extensions"
+#  endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+    struct bidirectional_iterator_tag;
+    struct random_access_iterator_tag;
+_LIBCPP_END_NAMESPACE_STD
+
+#  if defined(Q_CC_CLANG)
+#   pragma GCC diagnostic pop
+#  endif
+# else
 namespace std {
     struct bidirectional_iterator_tag;
     struct random_access_iterator_tag;
 }
+# endif
 #endif
 
 QT_BEGIN_NAMESPACE
