fill.fail.cpp 914 B

123456789101112131415161718192021222324252627282930
  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. // <array>
  9. // void fill(const T& u);
  10. #include <array>
  11. #include <cassert>
  12. // std::array is explicitly allowed to be initialized with A a = { init-list };.
  13. // Disable the missing braces warning for this reason.
  14. #include "disable_missing_braces_warning.h"
  15. int main(int, char**) {
  16. {
  17. typedef double T;
  18. typedef std::array<const T, 0> C;
  19. C c = {};
  20. // expected-error-re@array:* {{static_assert failed {{.*}}"cannot fill zero-sized array of type 'const T'"}}
  21. c.fill(5.5); // expected-note {{requested here}}
  22. }
  23. return 0;
  24. }