15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric 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
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <array>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // template <size_t I, class T, size_t N> T& get(array<T, N>& a);
125a83710eSEric Fiselier 
132decfad7SEric Fiselier // Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify.
142decfad7SEric Fiselier #if defined(__clang__)
152decfad7SEric Fiselier #pragma clang diagnostic ignored "-Warray-bounds"
162decfad7SEric Fiselier #endif
172decfad7SEric Fiselier 
185a83710eSEric Fiselier #include <array>
195a83710eSEric Fiselier #include <cassert>
205a83710eSEric Fiselier 
21b4e2e7a2SEric Fiselier 
22b4e2e7a2SEric Fiselier // std::array is explicitly allowed to be initialized with A a = { init-list };.
23b4e2e7a2SEric Fiselier // Disable the missing braces warning for this reason.
24b4e2e7a2SEric Fiselier #include "disable_missing_braces_warning.h"
252decfad7SEric Fiselier 
26*2df59c50SJF Bastien int main(int, char**)
275a83710eSEric Fiselier {
285a83710eSEric Fiselier     {
295a83710eSEric Fiselier         typedef double T;
305a83710eSEric Fiselier         typedef std::array<T, 3> C;
315a83710eSEric Fiselier         C c = {1, 2, 3.5};
32abd52cadSEric Fiselier         std::get<3>(c) = 5.5; // expected-note {{requested here}}
33241c73b1SEric Fiselier         // expected-error-re@array:* {{static_assert failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}} "Index out of bounds in std::get<> (std::array)"}}
345a83710eSEric Fiselier     }
35*2df59c50SJF Bastien 
36*2df59c50SJF Bastien   return 0;
375a83710eSEric Fiselier }
38