allocate.fail.cpp 973 B

1234567891011121314151617181920212223242526272829
  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. // <memory>
  9. // allocator:
  10. // pointer allocate(size_type n, allocator<void>::const_pointer hint=0);
  11. // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
  12. // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
  13. #include <memory>
  14. #include <cassert>
  15. #include "test_macros.h"
  16. int main(int, char**)
  17. {
  18. std::allocator<int> a;
  19. a.allocate(3); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
  20. a.allocate(3, nullptr); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
  21. return 0;
  22. }