154e3fc35SLouis Dionne //===----------------------------------------------------------------------===//
254e3fc35SLouis Dionne //
354e3fc35SLouis Dionne // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
454e3fc35SLouis Dionne // See https://llvm.org/LICENSE.txt for license information.
554e3fc35SLouis Dionne // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
654e3fc35SLouis Dionne //
754e3fc35SLouis Dionne //===----------------------------------------------------------------------===//
854e3fc35SLouis Dionne 
954e3fc35SLouis Dionne // [[nodiscard]] void* operator new[](std::size_t);
1054e3fc35SLouis Dionne // [[nodiscard]] void* operator new[](std::size_t, std::nothrow_t const&);
1154e3fc35SLouis Dionne // [[nodiscard]] void* operator new[](std::size_t, std::align_val_t);
1254e3fc35SLouis Dionne // [[nodiscard]] void* operator new[](std::size_t, std::align_val_t, std::nothrow_t const&);
1354e3fc35SLouis Dionne 
1454e3fc35SLouis Dionne // [[nodiscard]] is not supported at all in c++03
1554e3fc35SLouis Dionne // UNSUPPORTED: c++03
1654e3fc35SLouis Dionne 
1754e3fc35SLouis Dionne // [[nodiscard]] enabled before C++20 in libc++ as an extension
1854e3fc35SLouis Dionne // UNSUPPORTED: (c++11 || c++14 || c++17) && !stdlib=libc++
1954e3fc35SLouis Dionne 
2054e3fc35SLouis Dionne // Libc++ when built for z/OS doesn't contain the aligned allocation functions,
2154e3fc35SLouis Dionne // nor does the dynamic library shipped with z/OS.
22*1197fcabSAbhina Sree // XFAIL: target={{.+}}-zos{{.*}}
2354e3fc35SLouis Dionne 
2454e3fc35SLouis Dionne #include <new>
2554e3fc35SLouis Dionne 
2654e3fc35SLouis Dionne #include "test_macros.h"
2754e3fc35SLouis Dionne 
f()2854e3fc35SLouis Dionne void f() {
2954e3fc35SLouis Dionne     ::operator new[](4);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
3054e3fc35SLouis Dionne     ::operator new[](4, std::nothrow);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
3154e3fc35SLouis Dionne 
3254e3fc35SLouis Dionne #if TEST_STD_VER >= 17
3354e3fc35SLouis Dionne     ::operator new[](4, std::align_val_t{4});  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
3454e3fc35SLouis Dionne     ::operator new[](4, std::align_val_t{4}, std::nothrow);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
3554e3fc35SLouis Dionne #endif
3654e3fc35SLouis Dionne }
37