db_indexing.pass.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // UNSUPPORTED: c++98, c++03
  9. // MODULES_DEFINES: _LIBCPP_DEBUG=1
  10. // Can't test the system lib because this test enables debug mode
  11. // UNSUPPORTED: with_system_cxx_lib
  12. // test array<T, 0>::operator[] raises a debug error.
  13. #define _LIBCPP_DEBUG 1
  14. #include <array>
  15. #include "debug_mode_helper.h"
  16. int main(int, char**)
  17. {
  18. {
  19. typedef std::array<int, 0> C;
  20. C c = {};
  21. C const& cc = c;
  22. EXPECT_DEATH( c[0] );
  23. EXPECT_DEATH( c[1] );
  24. EXPECT_DEATH( cc[0] );
  25. EXPECT_DEATH( cc[1] );
  26. }
  27. {
  28. typedef std::array<const int, 0> C;
  29. C c = {{}};
  30. C const& cc = c;
  31. EXPECT_DEATH( c[0] );
  32. EXPECT_DEATH( c[1] );
  33. EXPECT_DEATH( cc[0] );
  34. EXPECT_DEATH( cc[1] );
  35. }
  36. return 0;
  37. }