db_indexing.pass.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. // UNSUPPORTED: windows
  10. // MODULES_DEFINES: _LIBCPP_DEBUG=1
  11. // Can't test the system lib because this test enables debug mode
  12. // UNSUPPORTED: with_system_cxx_lib
  13. // test array<T, 0>::operator[] raises a debug error.
  14. #define _LIBCPP_DEBUG 1
  15. #include <array>
  16. #include "debug_mode_helper.h"
  17. int main(int, char**)
  18. {
  19. {
  20. typedef std::array<int, 0> C;
  21. C c = {};
  22. C const& cc = c;
  23. EXPECT_DEATH( c[0] );
  24. EXPECT_DEATH( c[1] );
  25. EXPECT_DEATH( cc[0] );
  26. EXPECT_DEATH( cc[1] );
  27. }
  28. {
  29. typedef std::array<const int, 0> C;
  30. C c = {{}};
  31. C const& cc = c;
  32. EXPECT_DEATH( c[0] );
  33. EXPECT_DEATH( c[1] );
  34. EXPECT_DEATH( cc[0] );
  35. EXPECT_DEATH( cc[1] );
  36. }
  37. return 0;
  38. }