summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/sequences/array/array.tuple
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2017-06-12 14:41:37 +0000
committerMarshall Clow <mclow.lists@gmail.com>2017-06-12 14:41:37 +0000
commit6db379a2c8bbc40f39a63c6c34216fe23c80127a (patch)
tree7653dfeedfe35508f246f7714578150fbe12ce09 /libcxx/test/std/containers/sequences/array/array.tuple
parent2e33bbaff0904a8568eac4c9329a39834edf2c68 (diff)
downloadbcm5719-llvm-6db379a2c8bbc40f39a63c6c34216fe23c80127a.tar.gz
bcm5719-llvm-6db379a2c8bbc40f39a63c6c34216fe23c80127a.zip
[array.tuple]/1 says that instantiating tuple_element<N, array<T, M>> is ill-formed if N >= M. We didn't do that. Add a static_assert to cause a failure, and a test that checks that we failed
llvm-svn: 305191
Diffstat (limited to 'libcxx/test/std/containers/sequences/array/array.tuple')
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp
new file mode 100644
index 00000000000..c9fe695f9cb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_element<I, array<T, N> >::type
+
+// 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>
+
+
+// std::array is explicitly allowed to be initialized with A a = { init-list };.
+// Disable the missing braces warning for this reason.
+#include "disable_missing_braces_warning.h"
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ std::tuple_element<3, C> foo; // expected-note {{requested here}}
+ // expected-error@array:* {{static_assert failed "Index out of bounds in std::tuple_element<> (std::array)"}}
+ }
+}
OpenPOWER on IntegriCloud