ldionne added a comment.
I think this should do it:
diff --git
a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.verify.cpp
similarity index 81%
rename from
libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
rename to
libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.verify.cpp
index 234efc83423b..a28e3fc9d1d7 100644
---
a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.fail.cpp
+++
b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.verify.cpp
@@ -18,6 +18,13 @@
// Try and cast away const.
+// This test only checks that we static_assert in any_cast when the
+// constraints are not respected, however Clang will sometimes emit
+// additional errors while trying to instantiate the rest of any_cast
+// following the static_assert. We ignore unexpected errors in
+// clang-verify to make the test more robust to changes in Clang.
+// ADDITIONAL_COMPILE_FLAGS: -Xclang -verify-ignore-unexpected=error
+
#include <any>
struct TestType {};
@@ -30,19 +37,15 @@ int main(int, char**)
any a;
- // expected-error@any:* {{drops 'const' qualifier}}
// expected-error-re@any:* {{static_assert failed{{.*}} "ValueType is
required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType &>(static_cast<any const&>(a)); // expected-note
{{requested here}}
- // expected-error@any:* {{cannot cast from lvalue of type 'const
TestType' to rvalue reference type 'TestType &&'; types are not compatible}}
// expected-error-re@any:* {{static_assert failed{{.*}} "ValueType is
required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType &&>(static_cast<any const&>(a)); // expected-note
{{requested here}}
- // expected-error@any:* {{drops 'const' qualifier}}
// expected-error-re@any:* {{static_assert failed{{.*}} "ValueType is
required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType2 &>(static_cast<any const&&>(a)); // expected-note
{{requested here}}
- // expected-error@any:* {{cannot cast from lvalue of type 'const
TestType2' to rvalue reference type 'TestType2 &&'; types are not compatible}}
// expected-error-re@any:* {{static_assert failed{{.*}} "ValueType is
required to be a const lvalue reference or a CopyConstructible type"}}
any_cast<TestType2 &&>(static_cast<any const&&>(a)); // expected-note
{{requested here}}
diff --git
a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp
b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.verify.cpp
similarity index 81%
rename from
libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp
rename to
libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.verify.cpp
index 44a67f7aa03d..ec40eeeec11b 100644
---
a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp
+++
b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.verify.cpp
@@ -24,6 +24,13 @@
// Test instantiating the any_cast with a non-copyable type.
+// This test only checks that we static_assert in any_cast when the
+// constraints are not respected, however Clang will sometimes emit
+// additional errors while trying to instantiate the rest of any_cast
+// following the static_assert. We ignore unexpected errors in
+// clang-verify to make the test more robust to changes in Clang.
+// ADDITIONAL_COMPILE_FLAGS: -Xclang -verify-ignore-unexpected=error
+
#include <any>
using std::any;
@@ -45,17 +52,14 @@ struct no_move {
int main(int, char**) {
any a;
// expected-error-re@any:* {{static_assert failed{{.*}} "ValueType is
required to be an lvalue reference or a CopyConstructible type"}}
- // expected-error@any:* {{static_cast from 'no_copy' to 'no_copy' uses
deleted function}}
any_cast<no_copy>(static_cast<any&>(a)); // expected-note {{requested
here}}
// expected-error-re@any:* {{static_assert failed{{.*}} "ValueType is
required to be a const lvalue reference or a CopyConstructible type"}}
- // expected-error@any:* {{static_cast from 'const no_copy' to 'no_copy'
uses deleted function}}
any_cast<no_copy>(static_cast<any const&>(a)); // expected-note
{{requested here}}
any_cast<no_copy>(static_cast<any &&>(a)); // OK
// expected-error-re@any:* {{static_assert failed{{.*}} "ValueType is
required to be an rvalue reference or a CopyConstructible type"}}
- // expected-error@any:* {{static_cast from 'typename
remove_reference<no_move &>::type' (aka 'no_move') to 'no_move' uses deleted
function}}
any_cast<no_move>(static_cast<any &&>(a));
return 0;
Use `git apply` -- in particular mind the renaming of the files.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110216/new/
https://reviews.llvm.org/D110216
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits