diff options
author | JF Bastien <jfbastien@apple.com> | 2019-02-04 20:31:13 +0000 |
---|---|---|
committer | JF Bastien <jfbastien@apple.com> | 2019-02-04 20:31:13 +0000 |
commit | 2df59c50688c122bbcae7467d3eaf862c3ea3088 (patch) | |
tree | 29c9a3e1c54fe76a506ffecc0cc4d8fbaba5cb04 /libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper | |
parent | 6fd4e7fe0258ff71fe759535236883ea9060587c (diff) | |
download | bcm5719-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/tuple/tuple.tuple/tuple.helper')
12 files changed, 36 insertions, 12 deletions
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp index e56f86a1cca..a97e60ca779 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp @@ -40,7 +40,7 @@ void test() static_assert((std::is_same<typename std::tuple_element<idx, const volatile T>::type, const volatile U>::value), ""); } -int main() +int main(int, char**) { test<std::array<int, 5>, 5, int, 0>(); test<std::array<int, 5>, 5, int, 1>(); @@ -48,4 +48,6 @@ int main() test<std::array<volatile int, 4>, 4, volatile int, 3>(); test<std::array<char *, 3>, 3, char *, 1>(); test<std::array<char *, 3>, 3, char *, 2>(); + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp index eb1704c943b..fdfb8b8b0a8 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp @@ -38,7 +38,7 @@ void test() static_assert((std::is_same<typename std::tuple_element<idx, const volatile T>::type, const volatile U>::value), ""); } -int main() +int main(int, char**) { test<std::pair<int, int>, 2, int, 0>(); test<std::pair<int, int>, 2, int, 1>(); @@ -46,4 +46,6 @@ int main() test<std::pair<int, volatile int>, 2, volatile int, 1>(); test<std::pair<char *, int>, 2, char *, 0>(); test<std::pair<char *, int>, 2, int, 1>(); + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp index a1c42921ba2..24b735b7e68 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp @@ -22,7 +22,7 @@ #include <tuple> #include <type_traits> -int main() +int main(int, char**) { using T = std::tuple<int, long, void*>; using E1 = typename std::tuple_element<1, T &>::type; // expected-error{{undefined template}} @@ -30,4 +30,6 @@ int main() using E3 = typename std::tuple_element<4, T const>::type; // expected-error@__tuple:* 2 {{static_assert failed}} + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp index ecb6ea087ef..5ad2b08220e 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp @@ -39,7 +39,7 @@ void test() #endif } -int main() +int main(int, char**) { test<std::tuple<int>, 0, int>(); test<std::tuple<char, int>, 0, char>(); @@ -47,4 +47,6 @@ int main() test<std::tuple<int*, char, int>, 0, int*>(); test<std::tuple<int*, char, int>, 1, char>(); test<std::tuple<int*, char, int>, 2, int>(); + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp index aa20818393b..9b065b3b9f6 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp @@ -18,9 +18,11 @@ #include <tuple> -int main() +int main(int, char**) { (void)std::tuple_size<std::tuple<> &>::value; // expected-error {{implicit instantiation of undefined template}} (void)std::tuple_size<int>::value; // expected-error {{implicit instantiation of undefined template}} (void)std::tuple_size<std::tuple<>*>::value; // expected-error {{implicit instantiation of undefined template}} + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp index 2a602b1ca26..f27c7eb470a 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp @@ -32,10 +32,12 @@ void test() std::tuple_size<const volatile T> >::value), ""); } -int main() +int main(int, char**) { test<std::tuple<>, 0>(); test<std::tuple<int>, 1>(); test<std::tuple<char, int>, 2>(); test<std::tuple<char, char*, int>, 3>(); + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp index 3d092506828..83b773abf22 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.fail.cpp @@ -39,7 +39,7 @@ public: template <> struct std::tuple_size<Dummy3> {}; -int main() +int main(int, char**) { // Test that tuple_size<const T> is not incomplete when tuple_size<T>::value // is well-formed but not a constant expression. @@ -59,4 +59,6 @@ int main() // expected-error@__tuple:* 1 {{no member named 'value'}} (void)std::tuple_size<const Dummy3>::value; // expected-note {{here}} } + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp index 44e100c6d36..32bad3317bc 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp @@ -50,7 +50,7 @@ void test_incomplete() { } -int main() +int main(int, char**) { test_complete<std::tuple<> >(); test_complete<std::tuple<int&> >(); @@ -63,4 +63,6 @@ int main() test_incomplete<int>(); test_incomplete<std::tuple<int>&>(); test_incomplete<Dummy2>(); + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp index f191f9f64d7..00f7ff26972 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp @@ -139,11 +139,13 @@ void test_after_tuple_size_specialization() { assert(p == -1); } -int main() { +int main(int, char**) { test_decomp_user_type(); test_decomp_tuple(); test_decomp_pair(); test_decomp_array(); test_before_tuple_size_specialization(); test_after_tuple_size_specialization(); + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp index 820cb0443f8..8bd3fbd579e 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp @@ -16,10 +16,12 @@ #include <tuple> -int main() +int main(int, char**) { (void)std::tuple_size_v<std::tuple<> &>; // expected-note {{requested here}} (void)std::tuple_size_v<int>; // expected-note {{requested here}} (void)std::tuple_size_v<std::tuple<>*>; // expected-note {{requested here}} // expected-error@tuple:* 3 {{implicit instantiation of undefined template}} + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.pass.cpp index b2b3e72b9be..bd01f49497c 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.pass.cpp @@ -26,7 +26,7 @@ void test() static_assert(std::tuple_size_v<Tuple const volatile> == std::tuple_size<Tuple>::value, ""); } -int main() +int main(int, char**) { test<std::tuple<>, 0>(); @@ -39,4 +39,6 @@ int main() test<std::tuple<int, int, int>, 3>(); test<std::array<int, 3>, 3>(); + + return 0; } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_value_sfinae.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_value_sfinae.pass.cpp index 9c00418768f..2efbfa50e15 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_value_sfinae.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_value_sfinae.pass.cpp @@ -27,7 +27,7 @@ template <class T> constexpr bool has_value() { return has_value<T>(0); } struct Dummy {}; -int main() { +int main(int, char**) { // Test that the ::value member does not exist static_assert(has_value<std::tuple<int> const>(), ""); static_assert(has_value<std::pair<int, long> volatile>(), ""); @@ -35,4 +35,6 @@ int main() { static_assert(!has_value<const int>(), ""); static_assert(!has_value<volatile void>(), ""); static_assert(!has_value<const volatile std::tuple<int>&>(), ""); + + return 0; } |