brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 509fa98 Raw
37 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// [[nodiscard]] void* operator new[](std::size_t);10// [[nodiscard]] void* operator new[](std::size_t, std::nothrow_t const&);11// [[nodiscard]] void* operator new[](std::size_t, std::align_val_t);12// [[nodiscard]] void* operator new[](std::size_t, std::align_val_t, std::nothrow_t const&);13 14// [[nodiscard]] is not supported at all in c++0315// UNSUPPORTED: c++0316 17// [[nodiscard]] enabled before C++20 in libc++ as an extension18// UNSUPPORTED: (c++11 || c++14 || c++17) && !stdlib=libc++19 20// Libc++ when built for z/OS doesn't contain the aligned allocation functions,21// nor does the dynamic library shipped with z/OS.22// XFAIL: target={{.+}}-zos{{.*}}23 24#include <new>25 26#include "test_macros.h"27 28void f() {29    ::operator new[](4);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}30    ::operator new[](4, std::nothrow);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}31 32#if TEST_STD_VER >= 1733    ::operator new[](4, std::align_val_t{4});  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}34    ::operator new[](4, std::align_val_t{4}, std::nothrow);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}35#endif36}37