Marshall Clow | a46482e | 2012-12-18 16:46:30 +0000 | [diff] [blame] | 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 | |
Eric Fiselier | 02bb4bd | 2015-07-18 23:56:04 +0000 | [diff] [blame] | 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 | |
Marshall Clow | a46482e | 2012-12-18 16:46:30 +0000 | [diff] [blame] | 19 | #include <array> |
| 20 | #include <cassert> |
| 21 | |
Eric Fiselier | b47a434 | 2015-07-28 07:31:50 +0000 | [diff] [blame] | 22 | #include "test_macros.h" |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 23 | #include "../suppress_array_warnings.h" |
Eric Fiselier | 02bb4bd | 2015-07-18 23:56:04 +0000 | [diff] [blame] | 24 | |
Marshall Clow | a46482e | 2012-12-18 16:46:30 +0000 | [diff] [blame] | 25 | int main() |
| 26 | { |
| 27 | { |
| 28 | typedef double T; |
| 29 | typedef std::array<T, 3> C; |
| 30 | C c = {1, 2, 3.5}; |
Eric Fiselier | b47a434 | 2015-07-28 07:31:50 +0000 | [diff] [blame] | 31 | std::get<3>(c) = 5.5; // expected-note {{requested here}} |
| 32 | #if TEST_STD_VER >= 11 |
| 33 | // expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}} |
| 34 | #else |
| 35 | // expected-error@array:* {{implicit instantiation of undefined template '__static_assert_test<false>'}} |
| 36 | #endif |
Marshall Clow | a46482e | 2012-12-18 16:46:30 +0000 | [diff] [blame] | 37 | } |
| 38 | } |