From 74cb4f5f4649a6b574c8411ac7a53cbd7098752e Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 17 Jan 2018 22:48:09 +0000 Subject: [PATCH] Fix nodiscard failure tests on compilers w/o -verify. Previously .fail.cpp tests for nodiscard were run with -Wunused-result being a warning, not an error, when the compiler didn't support -verify. When -verify isn't enabled this change judiciously adds -Werror=unused-result when to only the failure tests containing the // expected-error string for nodiscard. As a drive-by change, this patch also adds a missing // UNSUPPORTED: c++2a to a test which was only supposed to run in C++ <= 11. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322776 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../new.delete.array/sized_delete_array11.pass.cpp | 2 +- utils/libcxx/test/format.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp index 862318d0b..ef9ec2db9 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp @@ -12,7 +12,7 @@ // 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 diff --git a/utils/libcxx/test/format.py b/utils/libcxx/test/format.py index 317fc8079..74e3cc0aa 100644 --- a/utils/libcxx/test/format.py +++ b/utils/libcxx/test/format.py @@ -242,7 +242,18 @@ class LibcxxTestFormat(object): 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: