1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <array> 11 12 // template <size_t I, class T, size_t N> T& get(array<T, N>& a); 13 14 // Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify. 15 #if defined(__clang__) 16 #pragma clang diagnostic ignored "-Warray-bounds" 17 #endif 18 19 #include <array> 20 #include <cassert> 21 22 #include "test_macros.h" 23 24 // std::array is explicitly allowed to be initialized with A a = { init-list };. 25 // Disable the missing braces warning for this reason. 26 #include "disable_missing_braces_warning.h" 27 28 int main() 29 { 30 { 31 typedef double T; 32 typedef std::array<T, 3> C; 33 C c = {1, 2, 3.5}; 34 std::get<3>(c) = 5.5; // expected-note {{requested here}} 35 #if TEST_STD_VER >= 11 36 // expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}} 37 #else 38 // expected-error@array:* {{implicit instantiation of undefined template '__static_assert_test<false>'}} 39 #endif 40 } 41 } 42