159cdf90aSEric Fiselier //===----------------------------------------------------------------------===//
259cdf90aSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
659cdf90aSEric Fiselier //
759cdf90aSEric Fiselier //===----------------------------------------------------------------------===//
859cdf90aSEric Fiselier 
959cdf90aSEric Fiselier // <array>
1059cdf90aSEric Fiselier 
1159cdf90aSEric Fiselier // bool operator==(array<T, N> const&, array<T, N> const&);
1259cdf90aSEric Fiselier // bool operator!=(array<T, N> const&, array<T, N> const&);
1359cdf90aSEric Fiselier // bool operator<(array<T, N> const&, array<T, N> const&);
1459cdf90aSEric Fiselier // bool operator<=(array<T, N> const&, array<T, N> const&);
1559cdf90aSEric Fiselier // bool operator>(array<T, N> const&, array<T, N> const&);
1659cdf90aSEric Fiselier // bool operator>=(array<T, N> const&, array<T, N> const&);
1759cdf90aSEric Fiselier 
1859cdf90aSEric Fiselier 
1959cdf90aSEric Fiselier #include <array>
2059cdf90aSEric Fiselier #include <vector>
2159cdf90aSEric Fiselier #include <cassert>
2259cdf90aSEric Fiselier 
2359cdf90aSEric Fiselier #include "test_macros.h"
2459cdf90aSEric Fiselier 
2559cdf90aSEric Fiselier template <class Array>
test_compare(const Array & LHS,const Array & RHS)2659cdf90aSEric Fiselier void test_compare(const Array& LHS, const Array& RHS) {
2759cdf90aSEric Fiselier   typedef std::vector<typename Array::value_type> Vector;
2859cdf90aSEric Fiselier   const Vector LHSV(LHS.begin(), LHS.end());
2959cdf90aSEric Fiselier   const Vector RHSV(RHS.begin(), RHS.end());
3059cdf90aSEric Fiselier   assert((LHS == RHS) == (LHSV == RHSV));
3159cdf90aSEric Fiselier   assert((LHS != RHS) == (LHSV != RHSV));
3259cdf90aSEric Fiselier   assert((LHS < RHS) == (LHSV < RHSV));
3359cdf90aSEric Fiselier   assert((LHS <= RHS) == (LHSV <= RHSV));
3459cdf90aSEric Fiselier   assert((LHS > RHS) == (LHSV > RHSV));
3559cdf90aSEric Fiselier   assert((LHS >= RHS) == (LHSV >= RHSV));
3659cdf90aSEric Fiselier }
3759cdf90aSEric Fiselier 
3859cdf90aSEric Fiselier template <int Dummy> struct NoCompare {};
3959cdf90aSEric Fiselier 
main(int,char **)402df59c50SJF Bastien int main(int, char**)
4159cdf90aSEric Fiselier {
4259cdf90aSEric Fiselier   {
4359cdf90aSEric Fiselier     typedef NoCompare<0> T;
4459cdf90aSEric Fiselier     typedef std::array<T, 3> C;
4559cdf90aSEric Fiselier     C c1 = {{}};
46*134723edSLouis Dionne     // expected-error@*:* 2 {{invalid operands to binary expression}}
4759cdf90aSEric Fiselier     TEST_IGNORE_NODISCARD (c1 == c1);
4859cdf90aSEric Fiselier     TEST_IGNORE_NODISCARD (c1 < c1);
4959cdf90aSEric Fiselier   }
5059cdf90aSEric Fiselier   {
5159cdf90aSEric Fiselier     typedef NoCompare<1> T;
5259cdf90aSEric Fiselier     typedef std::array<T, 3> C;
5359cdf90aSEric Fiselier     C c1 = {{}};
54*134723edSLouis Dionne     // expected-error@*:* 2 {{invalid operands to binary expression}}
5559cdf90aSEric Fiselier     TEST_IGNORE_NODISCARD (c1 != c1);
5659cdf90aSEric Fiselier     TEST_IGNORE_NODISCARD (c1 > c1);
5759cdf90aSEric Fiselier   }
5859cdf90aSEric Fiselier   {
5959cdf90aSEric Fiselier     typedef NoCompare<2> T;
6059cdf90aSEric Fiselier     typedef std::array<T, 0> C;
6159cdf90aSEric Fiselier     C c1 = {{}};
62*134723edSLouis Dionne     // expected-error@*:* 2 {{invalid operands to binary expression}}
6359cdf90aSEric Fiselier     TEST_IGNORE_NODISCARD (c1 == c1);
6459cdf90aSEric Fiselier     TEST_IGNORE_NODISCARD (c1 < c1);
6559cdf90aSEric Fiselier   }
662df59c50SJF Bastien 
672df59c50SJF Bastien   return 0;
6859cdf90aSEric Fiselier }
69