[libcxx-commits] [libcxx] 048688f - [libc++] Fix incorrect main() signatures in the tests
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 20 13:29:41 PDT 2021
Author: Louis Dionne
Date: 2021-10-20T16:26:34-04:00
New Revision: 048688fd80fadce1c72c365b0d74599a33389cfb
URL: https://github.com/llvm/llvm-project/commit/048688fd80fadce1c72c365b0d74599a33389cfb
DIFF: https://github.com/llvm/llvm-project/commit/048688fd80fadce1c72c365b0d74599a33389cfb.diff
LOG: [libc++] Fix incorrect main() signatures in the tests
Those creep up from time to time. We need to use `int main(int, char**)`
because in freestanding mode, `main` doesn't get special treatment and
special mangling, so we setup a symbol alias from the mangled version of
`main(int, char**)` to `extern "C" main`. That only works if all the tests
are consistent about how they define their main function.
Added:
Modified:
libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/deduct.pass.cpp
libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor2.pass.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/PR38601.pass.cpp
libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_equal/cmp_equal.pass.cpp
libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_greater/cmp_greater.pass.cpp
libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_greater_equal/cmp_greater_equal.pass.cpp
libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_less/cmp_less.pass.cpp
libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_less_equal/cmp_less_equal.pass.cpp
libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_not_equal/cmp_not_equal.pass.cpp
libcxx/test/std/utilities/utility/utility.intcmp/intcmp.fail.cpp
libcxx/test/std/utilities/utility/utility.intcmp/intcmp.in_range/in_range.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/deduct.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/deduct.pass.cpp
index 56a226d0096e5..5f56ca2853582 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/deduct.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/deduct.pass.cpp
@@ -15,8 +15,7 @@
#include <functional>
-int main()
-{
+int main(int, char**) {
int i = 0;
std::reference_wrapper ri(i);
static_assert(std::is_same_v<decltype(ri), std::reference_wrapper<int>>);
@@ -27,4 +26,6 @@ int main()
static_assert(std::is_same_v<decltype(rj), std::reference_wrapper<const int>>);
std::reference_wrapper rj2(rj);
static_assert(std::is_same_v<decltype(rj2), std::reference_wrapper<const int>>);
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
index 01fe619f41fa6..be9261a5c55c2 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
@@ -52,7 +52,7 @@ test(T& t)
void f() {}
-int main()
+int main(int, char**)
{
convertible_to_int_ref convi;
test(convi);
@@ -80,4 +80,6 @@ int main()
static_assert((std::is_same<decltype(rj), std::reference_wrapper<const int>>::value), "" );
}
#endif
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor2.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor2.pass.cpp
index b67667dc3fefb..30d7cdb4a38b4 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor2.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor2.pass.cpp
@@ -29,7 +29,7 @@ struct A2 {
operator B& () const noexcept { return b; }
};
-int main()
+int main(int, char**)
{
{
std::reference_wrapper<B> b1 = A1();
@@ -60,4 +60,6 @@ int main()
static_assert(std::is_assignable<std::reference_wrapper<B>, A2>::value, "");
static_assert(std::is_nothrow_assignable<std::reference_wrapper<B>, A2>::value, "");
}
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/PR38601.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/PR38601.pass.cpp
index 7fb0e8904df57..2b581b4594863 100644
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/PR38601.pass.cpp
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/PR38601.pass.cpp
@@ -22,7 +22,7 @@ struct Derived : Base {
int x_;
};
-int main() {
+int main(int, char**) {
Derived d(1, 2, 3);
Base b = static_cast<Base>(d);
assert(std::get<0>(b) == 2);
diff --git a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_equal/cmp_equal.pass.cpp b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_equal/cmp_equal.pass.cpp
index 7e88e4bd4383a..b57ea44863387 100644
--- a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_equal/cmp_equal.pass.cpp
+++ b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_equal/cmp_equal.pass.cpp
@@ -99,7 +99,7 @@ constexpr bool test() {
return true;
}
-int main() {
+int main(int, char**) {
ASSERT_NOEXCEPT(std::cmp_equal(0, 0));
test();
static_assert(test());
diff --git a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_greater/cmp_greater.pass.cpp b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_greater/cmp_greater.pass.cpp
index 0182c4521b9a5..b8afc7d6d2aee 100644
--- a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_greater/cmp_greater.pass.cpp
+++ b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_greater/cmp_greater.pass.cpp
@@ -90,7 +90,7 @@ constexpr bool test() {
return true;
}
-int main() {
+int main(int, char**) {
ASSERT_NOEXCEPT(std::cmp_greater(1, 0));
test();
static_assert(test());
diff --git a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_greater_equal/cmp_greater_equal.pass.cpp b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_greater_equal/cmp_greater_equal.pass.cpp
index 4b256152042ed..d166633de0924 100644
--- a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_greater_equal/cmp_greater_equal.pass.cpp
+++ b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_greater_equal/cmp_greater_equal.pass.cpp
@@ -92,7 +92,7 @@ constexpr bool test() {
return true;
}
-int main() {
+int main(int, char**) {
ASSERT_NOEXCEPT(std::cmp_greater_equal(1, 0));
test();
static_assert(test());
diff --git a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_less/cmp_less.pass.cpp b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_less/cmp_less.pass.cpp
index 70edebf300de4..bc39fa6102276 100644
--- a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_less/cmp_less.pass.cpp
+++ b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_less/cmp_less.pass.cpp
@@ -91,7 +91,7 @@ constexpr bool test() {
return true;
}
-int main() {
+int main(int, char**) {
ASSERT_NOEXCEPT(std::cmp_less(0, 1));
test();
static_assert(test());
diff --git a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_less_equal/cmp_less_equal.pass.cpp b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_less_equal/cmp_less_equal.pass.cpp
index 78c3c2aeefad6..2dc6d1be00729 100644
--- a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_less_equal/cmp_less_equal.pass.cpp
+++ b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_less_equal/cmp_less_equal.pass.cpp
@@ -91,7 +91,7 @@ constexpr bool test() {
return true;
}
-int main() {
+int main(int, char**) {
ASSERT_NOEXCEPT(std::cmp_less_equal(0, 1));
test();
static_assert(test());
diff --git a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_not_equal/cmp_not_equal.pass.cpp b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_not_equal/cmp_not_equal.pass.cpp
index 70c29016907b4..97ab5426f6d18 100644
--- a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_not_equal/cmp_not_equal.pass.cpp
+++ b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.cmp_not_equal/cmp_not_equal.pass.cpp
@@ -98,7 +98,7 @@ constexpr bool test() {
return true;
}
-int main() {
+int main(int, char**) {
ASSERT_NOEXCEPT(std::cmp_not_equal(0, 0));
test();
static_assert(test());
diff --git a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.fail.cpp b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.fail.cpp
index 66e35adc40726..2705264486422 100644
--- a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.fail.cpp
+++ b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.fail.cpp
@@ -124,7 +124,7 @@ constexpr void test_uchars() {
}
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
-int main() {
+int main(int, char**) {
test<bool>();
test<char>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
diff --git a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.in_range/in_range.pass.cpp b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.in_range/in_range.pass.cpp
index 3946904f1e76a..31f77c4418721 100644
--- a/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.in_range/in_range.pass.cpp
+++ b/libcxx/test/std/utilities/utility/utility.intcmp/intcmp.in_range/in_range.pass.cpp
@@ -74,7 +74,7 @@ constexpr bool test() {
return true;
}
-int main() {
+int main(int, char**) {
ASSERT_NOEXCEPT(std::in_range<int>(-1));
test();
static_assert(test());
More information about the libcxx-commits
mailing list