Skip to content

Commit 504bc07

Browse files
committed
[runtimes] Use int main(int, char**) consistently in tests
This is needed when running the tests in Freestanding mode, where main() isn't treated specially. In Freestanding, main() doesn't get mangled as extern "C", so whatever runtime we're using fails to find the entry point. One way to solve this problem is to define a symbol alias from __Z4mainiPPc to _main, however this requires all definitions of main() to have the same mangling. Hence this commit.
1 parent 2b0c5d7 commit 504bc07

File tree

135 files changed

+269
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+269
-154
lines changed

libcxx/test/libcxx/depr/depr.c.headers/math_h.compile.pass.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,3 @@
2424
# error M_PI not defined
2525
# endif
2626
#endif
27-
28-
int main() { }

libcxx/test/libcxx/depr/depr.c.headers/stdint_h.std_types_t.compile.pass.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,5 +261,3 @@
261261
#ifndef UINTMAX_C
262262
#error UINTMAX_C not defined
263263
#endif
264-
265-
int main() { }

libcxx/test/libcxx/depr/depr.c.headers/stdint_h.xopen_source.compile.pass.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,5 +258,3 @@
258258
#ifndef UINTMAX_C
259259
#error UINTMAX_C not defined
260260
#endif
261-
262-
int main() { }

libcxx/test/libcxx/language.support/support.rtti/type.info/type_info.comparison.merged.sh.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ void register2();
3232
#elif defined(MAIN)
3333
std::vector<std::type_index> registry;
3434

35-
int main() {
35+
int main(int, char**) {
3636
register1();
3737
register2();
3838

3939
assert(registry.size() == 2);
4040
assert(registry[0] != registry[1]);
41+
return 0;
4142
}
4243
#else
4344
# error

libcxx/test/libcxx/language.support/support.rtti/type.info/type_info.comparison.unmerged.sh.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ void register2();
3232
#elif defined(MAIN)
3333
std::vector<std::type_index> registry;
3434

35-
int main() {
35+
int main(int, char**) {
3636
register1();
3737
register2();
3838

3939
assert(registry.size() == 2);
4040
assert(registry[0] == registry[1]);
41+
return 0;
4142
}
4243
#else
4344
# error

libcxx/test/libcxx/min_max_macros.compile.pass.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,5 +285,3 @@ TEST_MACROS();
285285
TEST_MACROS();
286286
#include <ext/hash_set>
287287
TEST_MACROS();
288-
289-
int main() { }

libcxx/test/libcxx/no_assert_include.compile.pass.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,3 @@
170170
#ifdef assert
171171
#error "Do not include cassert or assert.h in standard header files"
172172
#endif
173-
174-
int main() { }

libcxx/test/libcxx/numerics/clamp_to_integral.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void test_float() {
7777
}
7878
}
7979

80-
int main() {
80+
int main(int, char**) {
8181
test<short>();
8282
test<unsigned short>();
8383
test<int>();
@@ -87,4 +87,5 @@ int main() {
8787
test_float<short>();
8888
test_float<int>();
8989
test_float<long long>();
90+
return 0;
9091
}

libcxx/test/libcxx/selftest/compile.fail.cpp/compile-error.compile.fail.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
struct Foo { };
1212
typedef Foo::x x;
1313

14-
int main() { }
14+
int main(int, char**) { return 0; }

libcxx/test/libcxx/selftest/compile.fail.cpp/compile-success.compile.fail.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
// Make sure the test DOES NOT pass if it succeeds at compile-time
1212

13-
int main() { }
13+
int main(int, char**) { return 0; }

0 commit comments

Comments
 (0)