// Note that sized delete operator definitions below are simply ignored
// when sized deallocation is not supported, e.g., prior to C++14.
-// UNSUPPORTED: c++14, c++17
+// UNSUPPORTED: c++14, c++17, c++2a
// UNSUPPORTED: sanitizer-new-delete
#include <new>
test_cxx.useWarnings()
if '-Wuser-defined-warnings' in test_cxx.warning_flags:
test_cxx.warning_flags += ['-Wno-error=user-defined-warnings']
-
+ else:
+ # We still need to enable certain warnings on .fail.cpp test when
+ # -verify isn't enabled. Such as -Werror=unused-result. However,
+ # we don't want it enabled too liberally, which might incorrectly
+ # allow unrelated failure tests to 'pass'.
+ #
+ # Therefore, we check if the test was expected to fail because of
+ # nodiscard before enabling it
+ test_str = "ignoring return value of function declared with " \
+ + "'nodiscard' attribute"
+ if test_str in contents:
+ test_cxx.flags += ['-Werror=unused-result']
cmd, out, err, rc = test_cxx.compile(source_path, out=os.devnull)
expected_rc = 0 if use_verify else 1
if rc == expected_rc: