Fix warnings in array and assoc containers
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242629 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
47c5dae573
commit
02bb4bdb49
@ -1118,8 +1118,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp)
|
||||
|
||||
template <class _Tp, class _Compare, class _Allocator>
|
||||
__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
|
||||
: __pair1_(__node_allocator(__a)),
|
||||
__begin_node_(__node_pointer()),
|
||||
: __begin_node_(__node_pointer()),
|
||||
__pair1_(__node_allocator(__a)),
|
||||
__pair3_(0)
|
||||
{
|
||||
__begin_node() = __end_node();
|
||||
@ -1128,8 +1128,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
|
||||
template <class _Tp, class _Compare, class _Allocator>
|
||||
__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp,
|
||||
const allocator_type& __a)
|
||||
: __pair1_(__node_allocator(__a)),
|
||||
__begin_node_(__node_pointer()),
|
||||
: __begin_node_(__node_pointer()),
|
||||
__pair1_(__node_allocator(__a)),
|
||||
__pair3_(0, __comp)
|
||||
{
|
||||
__begin_node() = __end_node();
|
||||
|
@ -576,6 +576,7 @@ class Configuration(object):
|
||||
]
|
||||
self.cxx.addCompileFlagIfSupported('-Wno-attributes')
|
||||
if self.cxx.type == 'clang' or self.cxx.type == 'apple-clang':
|
||||
self.cxx.addCompileFlagIfSupported('-Wno-pessimizing-move')
|
||||
self.cxx.addCompileFlagIfSupported('-Wno-c++11-extensions')
|
||||
self.cxx.addCompileFlagIfSupported('-Wno-user-defined-literals')
|
||||
|
||||
|
@ -17,16 +17,36 @@
|
||||
// http://llvm.org/bugs/show_bug.cgi?id=16549
|
||||
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
struct Key {
|
||||
template <typename T> Key(const T&) {}
|
||||
bool operator< (const Key&) const { return false; }
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
int main()
|
||||
{
|
||||
std::map<Key, int>::iterator it = std::map<Key, int>().find(Key(0));
|
||||
std::pair<std::map<Key, int>::iterator, bool> result =
|
||||
std::map<Key, int>().insert(std::make_pair(Key(0), 0));
|
||||
typedef std::map<Key, int> MapT;
|
||||
typedef MapT::iterator Iter;
|
||||
typedef std::pair<Iter, bool> IterBool;
|
||||
{
|
||||
MapT m_empty;
|
||||
MapT m_contains;
|
||||
m_contains[Key(0)] = 42;
|
||||
|
||||
Iter it = m_empty.find(Key(0));
|
||||
assert(it == m_empty.end());
|
||||
it = m_contains.find(Key(0));
|
||||
assert(it != m_contains.end());
|
||||
}
|
||||
{
|
||||
MapT map;
|
||||
IterBool result = map.insert(std::make_pair(Key(0), 42));
|
||||
assert(result.second);
|
||||
assert(result.first->second = 42);
|
||||
IterBool result2 = map.insert(std::make_pair(Key(0), 43));
|
||||
assert(!result2.second);
|
||||
assert(map[Key(0)] == 42);
|
||||
}
|
||||
}
|
||||
|
@ -16,14 +16,14 @@
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "MoveOnly.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef std::pair<MoveOnly, double> V;
|
||||
std::map<MoveOnly, double> m;
|
||||
assert(m.size() == 0);
|
||||
assert(m[1] == 0.0);
|
||||
@ -37,8 +37,6 @@ int main()
|
||||
assert(m[6] == 6.5);
|
||||
assert(m.size() == 2);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::pair<MoveOnly, double> V;
|
||||
std::map<MoveOnly, double, std::less<MoveOnly>, min_allocator<V>> m;
|
||||
|
@ -21,4 +21,5 @@ int main()
|
||||
typedef std::multimap<int, int> M2;
|
||||
M2::iterator i;
|
||||
M1::iterator j = i;
|
||||
((void)j);
|
||||
}
|
||||
|
@ -21,4 +21,5 @@ int main()
|
||||
typedef std::multiset<int> M2;
|
||||
M2::iterator i;
|
||||
M1::iterator j = i;
|
||||
((void)j);
|
||||
}
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -11,15 +11,22 @@
|
||||
|
||||
// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
|
||||
|
||||
// Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify.
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
C c = {1, 2, 3.5};
|
||||
std::get<3>(c) = 5.5; // Can't get element 3!
|
||||
std::get<3>(c) = 5.5; // expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}}
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,17 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#if __cplusplus > 201103L
|
||||
#include "test_macros.h"
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
struct S {
|
||||
std::array<int, 3> a;
|
||||
int k;
|
||||
constexpr S() : a{1,2,3}, k(std::get<2>(a)) {}
|
||||
};
|
||||
};
|
||||
|
||||
constexpr std::array<int, 2> getArr () { return { 3, 4 }; }
|
||||
#endif
|
||||
@ -35,7 +40,7 @@ int main()
|
||||
assert(c[1] == 5.5);
|
||||
assert(c[2] == 3.5);
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
|
@ -14,6 +14,10 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -24,7 +28,7 @@ int main()
|
||||
assert(std::get<1>(c) == 2);
|
||||
assert(std::get<2>(c) == 3.5);
|
||||
}
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
|
@ -11,14 +11,18 @@
|
||||
|
||||
// template <size_t I, class T, size_t N> T&& get(array<T, N>&& a);
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
|
||||
#include "../suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
{
|
||||
typedef std::unique_ptr<double> T;
|
||||
typedef std::array<T, 1> C;
|
||||
@ -26,5 +30,4 @@ int main()
|
||||
T t = std::get<0>(std::move(c));
|
||||
assert(*t == 3.5);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
@ -17,6 +17,10 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
#include "suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -27,7 +31,7 @@ int main()
|
||||
assert(r1 == 1);
|
||||
r1 = 5.5;
|
||||
assert(c.front() == 5.5);
|
||||
|
||||
|
||||
C::reference r2 = c.at(2);
|
||||
assert(r2 == 3.5);
|
||||
r2 = 7.5;
|
||||
@ -50,7 +54,7 @@ int main()
|
||||
catch (const std::out_of_range &) {}
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -27,6 +29,4 @@ int main()
|
||||
*i = 5.5;
|
||||
assert(c[0] == 5.5);
|
||||
}
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,10 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
#include "suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -45,12 +49,12 @@ int main()
|
||||
assert(r2 == 3.5);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
constexpr C c = {1, 2, 3.5};
|
||||
|
||||
|
||||
constexpr T t1 = c.front();
|
||||
static_assert (t1 == 1, "");
|
||||
|
||||
|
@ -17,6 +17,10 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
#include "suppress_array_warnings.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -42,13 +46,13 @@ int main()
|
||||
C::const_reference r2 = c[2];
|
||||
assert(r2 == 3.5);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
constexpr C c = {1, 2, 3.5};
|
||||
|
||||
|
||||
constexpr T t1 = c[0];
|
||||
static_assert (t1 == 1, "");
|
||||
|
||||
|
@ -16,4 +16,5 @@
|
||||
int main()
|
||||
{
|
||||
std::error_category* p = 0;
|
||||
((void)p);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user