summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/function.objects/refwrap
diff options
context:
space:
mode:
authorJF Bastien <jfbastien@apple.com>2019-02-04 20:31:13 +0000
committerJF Bastien <jfbastien@apple.com>2019-02-04 20:31:13 +0000
commit2df59c50688c122bbcae7467d3eaf862c3ea3088 (patch)
tree29c9a3e1c54fe76a506ffecc0cc4d8fbaba5cb04 /libcxx/test/std/utilities/function.objects/refwrap
parent6fd4e7fe0258ff71fe759535236883ea9060587c (diff)
downloadbcm5719-llvm-2df59c50688c122bbcae7467d3eaf862c3ea3088.tar.gz
bcm5719-llvm-2df59c50688c122bbcae7467d3eaf862c3ea3088.zip
Support tests in freestanding
Summary: Freestanding is *weird*. The standard allows it to differ in a bunch of odd manners from regular C++, and the committee would like to improve that situation. I'd like to make libc++ behave better with what freestanding should be, so that it can be a tool we use in improving the standard. To do that we need to try stuff out, both with "freestanding the language mode" and "freestanding the library subset". Let's start with the super basic: run the libc++ tests in freestanding, using clang as the compiler, and see what works. The easiest hack to do this: In utils/libcxx/test/config.py add: self.cxx.compile_flags += ['-ffreestanding'] Run the tests and they all fail. Why? Because in freestanding `main` isn't special. This "not special" property has two effects: main doesn't get mangled, and main isn't allowed to omit its `return` statement. The first means main gets mangled and the linker can't create a valid executable for us to test. The second means we spew out warnings (ew) and the compiler doesn't insert the `return` we omitted, and main just falls of the end and does whatever undefined behavior (if you're luck, ud2 leading to non-zero return code). Let's start my work with the basics. This patch changes all libc++ tests to declare `main` as `int main(int, char**` so it mangles consistently (enabling us to declare another `extern "C"` main for freestanding which calls the mangled one), and adds `return 0;` to all places where it was missing. This touches 6124 files, and I apologize. The former was done with The Magic Of Sed. The later was done with a (not quite correct but decent) clang tool: https://gist.github.com/jfbastien/793819ff360baa845483dde81170feed This works for most tests, though I did have to adjust a few places when e.g. the test runs with `-x c`, macros are used for main (such as for the filesystem tests), etc. Once this is in we can create a freestanding bot which will prevent further regressions. After that, we can start the real work of supporting C++ freestanding fairly well in libc++. <rdar://problem/47754795> Reviewers: ldionne, mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, arphaman, miyuki, libcxx-commits Differential Revision: https://reviews.llvm.org/D57624 llvm-svn: 353086
Diffstat (limited to 'libcxx/test/std/utilities/function.objects/refwrap')
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/type.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/unwrap_ref_decay.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/unwrap_reference.pass.cpp4
-rw-r--r--libcxx/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp4
19 files changed, 57 insertions, 19 deletions
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
index 5e67db520fb..c15989f003e 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
@@ -30,7 +30,7 @@ test(T& t)
void f() {}
-int main()
+int main(int, char**)
{
void (*fp)() = f;
test(fp);
@@ -41,4 +41,6 @@ int main()
test(i);
const int j = 0;
test(j);
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
index 16ce961126c..3ef0cdda869 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
@@ -42,7 +42,7 @@ test_function()
assert(&r2.get() == &f);
}
-int main()
+int main(int, char**)
{
void (*fp)() = f;
test(fp);
@@ -53,4 +53,6 @@ int main()
test(i);
const int j = 0;
test(j);
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
index 64726b53ef8..355047d98ce 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
@@ -30,7 +30,7 @@ test(T& t)
void f() {}
-int main()
+int main(int, char**)
{
void (*fp)() = f;
test(fp);
@@ -41,4 +41,6 @@ int main()
test(i);
const int j = 0;
test(j);
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
index f7a6670b431..f02a9974d7d 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
@@ -17,7 +17,9 @@
#include <functional>
#include <cassert>
-int main()
+int main(int, char**)
{
std::reference_wrapper<const int> r(3);
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
index 2cbb1a010f1..a43d0fd2510 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
@@ -29,7 +29,7 @@ test(T& t)
void f() {}
-int main()
+int main(int, char**)
{
void (*fp)() = f;
test(fp);
@@ -40,4 +40,6 @@ int main()
test(i);
const int j = 0;
test(j);
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp
index b16a4b476c3..d4cb421f53e 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp
@@ -15,9 +15,11 @@
#include <functional>
#include <cassert>
-int main()
+int main(int, char**)
{
int i = 0;
std::reference_wrapper<const int> r = std::cref(i);
assert(&r.get() == &i);
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
index 3023f8da2a3..093b7e230fd 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
@@ -15,10 +15,12 @@
#include <functional>
#include <cassert>
-int main()
+int main(int, char**)
{
const int i = 0;
std::reference_wrapper<const int> r1 = std::cref(i);
std::reference_wrapper<const int> r2 = std::cref(r1);
assert(&r2.get() == &i);
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
index 9e283d1bfaf..c07028d21dd 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
@@ -22,7 +22,9 @@ struct A {};
const A source() {return A();}
-int main()
+int main(int, char**)
{
std::reference_wrapper<const A> r = std::ref(source());
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp
index a8af5aa4cfe..f64d8ad8cae 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp
@@ -15,9 +15,11 @@
#include <functional>
#include <cassert>
-int main()
+int main(int, char**)
{
int i = 0;
std::reference_wrapper<int> r = std::ref(i);
assert(&r.get() == &i);
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
index fee5009a73b..4fdaf992c64 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
@@ -22,7 +22,7 @@ bool is5 ( int i ) { return i == 5; }
template <typename T>
bool call_pred ( T pred ) { return pred(5); }
-int main()
+int main(int, char**)
{
{
int i = 0;
@@ -39,4 +39,6 @@ int main()
assert(call_pred(std::ref(cp)));
assert(cp.count() == 2);
}
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp
index 6302c51b8ad..d54d5184c65 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp
@@ -45,7 +45,9 @@ test_int_1()
}
}
-int main()
+int main(int, char**)
{
test_int_1();
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp
index 425bc6df0c8..fd31041330d 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp
@@ -319,10 +319,12 @@ testint_2()
}
}
-int main()
+int main(int, char**)
{
test_void_1();
test_int_1();
test_void_2();
testint_2();
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp
index 37d7cfca9de..67cf51f3359 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp
@@ -69,7 +69,9 @@ struct A_void_1
}
};
-int main()
+int main(int, char**)
{
test_int_0();
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp
index 735bfd890dd..18e65531333 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp
@@ -61,7 +61,9 @@ test_void_0()
}
}
-int main()
+int main(int, char**)
{
test_void_0();
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/type.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/type.pass.cpp
index ef46e15d0a0..d17ab8100ef 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/type.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/type.pass.cpp
@@ -17,7 +17,7 @@
class C {};
-int main()
+int main(int, char**)
{
static_assert((std::is_same<std::reference_wrapper<C>::type,
C>::value), "");
@@ -33,4 +33,6 @@ int main()
int*(C::*)(double*)>::value), "");
static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::type,
int (C::*)(double*) const volatile>::value), "");
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp
index 14a06a9c316..17eef26f07a 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/type_properties.pass.cpp
@@ -52,7 +52,7 @@ void test()
#endif
}
-int main()
+int main(int, char**)
{
test<int>();
test<double>();
@@ -60,4 +60,6 @@ int main()
#if TEST_STD_VER >= 11
test<MoveOnly>();
#endif
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/unwrap_ref_decay.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/unwrap_ref_decay.pass.cpp
index 9aaa2827997..1987898393c 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/unwrap_ref_decay.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/unwrap_ref_decay.pass.cpp
@@ -28,7 +28,7 @@ void check() {
struct T { };
-int main() {
+int main(int, char**) {
check<T, T>();
check<T&, T>();
check<T const, T>();
@@ -54,4 +54,6 @@ int main() {
check<std::reference_wrapper<T[3]>&, T (&)[3]>();
check<std::reference_wrapper<T ()>, T (&)()>();
check<std::reference_wrapper<T ()>&, T (&)()>();
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/unwrap_reference.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/unwrap_reference.pass.cpp
index f6d48a51e8b..209d5e2a0bc 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/unwrap_reference.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/unwrap_reference.pass.cpp
@@ -39,7 +39,7 @@ void check() {
struct T { };
-int main() {
+int main(int, char**) {
check<T>();
check<int>();
check<float>();
@@ -47,4 +47,6 @@ int main() {
check<T*>();
check<int*>();
check<float*>();
+
+ return 0;
}
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
index 50cda116932..5a6a41fdbe0 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
@@ -68,7 +68,7 @@ public:
static const bool value = sizeof(test<T>(0)) == 1;
};
-int main()
+int main(int, char**)
{
static_assert((std::is_same<std::reference_wrapper<functor1>::result_type,
char>::value), "");
@@ -93,4 +93,6 @@ int main()
static_assert(has_result_type<std::reference_wrapper<functor3> >::value, "");
static_assert(!has_result_type<std::reference_wrapper<functor4> >::value, "");
static_assert(!has_result_type<std::reference_wrapper<C> >::value, "");
+
+ return 0;
}
OpenPOWER on IntegriCloud