Skip to content

Commit e31322b

Browse files
authored
[libc++] Fix transform_error.mandates.verify.cpp test on msvc (#104635)
PR #102851 marks reference types in union as error on msvc by changing the clang, which makes 'transform_error.mandates.verify.cpp' no longer failing on msvc from ToT. However, all libcxx buildbots do not build clang from source, therefore, this test will still fail on these bots, which is incorrect. This patch changed the expected error message of this test so it can pass with both release branch clang and ToT clang.
1 parent 1fa6c99 commit e31322b

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1414

1515
// With clang-cl, some warnings have a 'which is a Microsoft extension' suffix
16-
// which break the tests.
17-
// XFAIL: msvc
16+
// which break the tests. But #102851 will turn it into an error, making the test pass.
17+
// However, upstream libcxx buildbots do not build clang from source while testing, so
18+
// this tests still expected to fail on these bots.
19+
//
20+
// TODO(LLVM 22): Remove '0-1' from 'expected-error-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}}}'
21+
// and remove 'expected-warning-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}, which is a Microsoft extension}}'
22+
// once LLVM 22 releases. See https://github.com/llvm/llvm-project/issues/104885.
1823

1924
// Test the mandates
2025

@@ -56,11 +61,12 @@ void test() {
5661
e.transform_error(return_unexpected<int&>); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}}
5762
// expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}}
5863
// expected-error-re@*:* {{static assertion failed {{.*}}[expected.object.general] A program that instantiates the definition of template expected<T, E> for {{.*}} is ill-formed.}}
59-
// expected-error-re@*:* {{union member {{.*}} has reference type {{.*}}}}
64+
// expected-error-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}}}
6065

6166
e.transform_error(return_no_object<int&>); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}}
6267
// expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}}
6368
// expected-error-re@*:* {{static assertion failed {{.*}}[expected.object.general] A program that instantiates the definition of template expected<T, E> for {{.*}} is ill-formed.}}
69+
// expected-warning-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}, which is a Microsoft extension}}
6470
}
6571

6672
// Test const& overload

libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1414

1515
// With clang-cl, some warnings have a 'which is a Microsoft extension' suffix
16-
// which break the tests.
17-
// XFAIL: msvc
16+
// which break the tests. But #102851 will turn it into an error, making the test pass.
17+
// However, upstream libcxx buildbots do not build clang from source while testing, so
18+
// this tests still expected to fail on these bots.
19+
//
20+
// TODO(LLVM 22): Remove '0-1' from 'expected-error-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}}}'
21+
// and remove 'expected-warning-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}, which is a Microsoft extension}}'
22+
// and remove 'expected-error-re@*:* 0-1 {{call to deleted constructor of {{.*}}}}'
23+
// once LLVM 22 releases. See See https://github.com/llvm/llvm-project/issues/104885.
1824

1925
// Test the mandates
2026

@@ -57,11 +63,12 @@ void test() {
5763
// expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}}
5864
// expected-error-re@*:* {{static assertion failed {{.*}}A program that instantiates expected<T, E> with a E that is not a valid argument for unexpected<E> is ill-formed}}
5965
// expected-error-re@*:* 0-1 {{call to deleted constructor of {{.*}}}}
60-
// expected-error-re@*:* {{union member {{.*}} has reference type {{.*}}}}
66+
// expected-error-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}}}
6167

6268
e.transform_error(return_no_object<int&>); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}}
6369
// expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}}
6470
// expected-error-re@*:* {{static assertion failed {{.*}}A program that instantiates expected<T, E> with a E that is not a valid argument for unexpected<E> is ill-formed}}
71+
// expected-warning-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}, which is a Microsoft extension}}
6572
}
6673

6774
// Test const& overload
@@ -71,6 +78,7 @@ void test() {
7178
// expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}}
7279
e.transform_error(return_no_object<const int &>); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}}
7380
// expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}}
81+
// expected-error-re@*:* 0-1 {{call to deleted constructor of {{.*}}}}
7482
}
7583

7684
// Test && overload

0 commit comments

Comments
 (0)