[runtimes][NFC] Consistently declare main() functions in tests (#162548)
In the libc++ test suite, we consistently declare main() functions with full parameters and explicitly return from the function. This helps code that compiles the tests with -ffreestanding, where main() is not a special function (with an implicit return and special mangling). This patch fixes a few stray declarations, including in libunwind and libc++abi.
This commit is contained in:
parent
5841319aca
commit
4f80c064eb
14 changed files with 32 additions and 22 deletions
|
|
@ -2222,10 +2222,11 @@ void test_utf16_ucs2_codecvts() {
|
|||
#endif
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(int, char**) {
|
||||
test_utf8_utf32_codecvts();
|
||||
test_utf8_utf16_codecvts();
|
||||
test_utf8_ucs2_codecvts();
|
||||
test_utf16_utf32_codecvts();
|
||||
test_utf16_ucs2_codecvts();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ constexpr bool test() {
|
|||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(int, char**) {
|
||||
test();
|
||||
static_assert(test());
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ def hasAnyLocale(config, locales):
|
|||
+ name_string_literals
|
||||
+ """, nullptr,
|
||||
};
|
||||
int main() {
|
||||
int main(int, char**) {
|
||||
for (size_t i = 0; test_locale_names[i]; i++) {
|
||||
if (::setlocale(LC_ALL, test_locale_names[i]) != NULL) {
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ def _getAndroidDeviceApi(cfg):
|
|||
r"""
|
||||
#include <android/api-level.h>
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
int main(int, char**) {
|
||||
printf("%d\n", android_get_device_api_level());
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ def _mingwSupportsModules(cfg):
|
|||
#else
|
||||
// __MINGW64_VERSION_MAJOR > 12 should be ok.
|
||||
#endif
|
||||
int main() { return 0; }
|
||||
int main(int, char**) { return 0; }
|
||||
""",
|
||||
)
|
||||
|
||||
|
|
@ -474,7 +474,7 @@ def _getLocaleFlagsAction(cfg, locale, alts, members):
|
|||
#include <wchar.h>
|
||||
|
||||
// Print each requested locale conversion member on separate lines.
|
||||
int main() {
|
||||
int main(int, char**) {
|
||||
const char* locales[] = { %s };
|
||||
for (int loc_i = 0; loc_i < %d; ++loc_i) {
|
||||
if (!setlocale(LC_ALL, locales[loc_i])) {
|
||||
|
|
@ -629,7 +629,7 @@ DEFAULT_FEATURES += [
|
|||
"""
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
int main() {
|
||||
int main(int, char**) {
|
||||
CHAR tempDirPath[MAX_PATH];
|
||||
DWORD tempPathRet = GetTempPathA(MAX_PATH, tempDirPath);
|
||||
if (tempPathRet == 0 || tempPathRet > MAX_PATH) {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@
|
|||
|
||||
// Android/Bionic does not support pthread_cancel.
|
||||
#ifdef __BIONIC__
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
int main(int, char**) { return 0; }
|
||||
#else
|
||||
|
||||
#include <chrono>
|
||||
|
|
@ -45,7 +43,7 @@ static void* test(void* arg) {
|
|||
return (void*)1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(int, char**) {
|
||||
pthread_t child_thread;
|
||||
std::unique_lock<std::mutex> lk(cv_m);
|
||||
pthread_create(&child_thread, 0, test, (void*)0);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void bazz() {
|
|||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(int, char**) {
|
||||
try {
|
||||
bazz();
|
||||
} catch (int i) {
|
||||
|
|
|
|||
|
|
@ -62,4 +62,7 @@ __attribute__((noinline)) void foo() {
|
|||
// smstop sm
|
||||
}
|
||||
|
||||
int main() { foo(); }
|
||||
int main(int, char **) {
|
||||
foo();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,10 +126,11 @@ extern "C" __attribute__((noinline)) void foo() {
|
|||
bar();
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(int, char**) {
|
||||
// Set signal handler for SIGSEGV.
|
||||
signal(SIGSEGV, handler);
|
||||
foo();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else // Assembly code for abc().
|
||||
|
|
|
|||
|
|
@ -77,4 +77,7 @@ extern "C" void stepper() {
|
|||
assert(unw_step(&cursor) <= 0);
|
||||
}
|
||||
|
||||
int main() { bad_unwind_info(); }
|
||||
int main(int, char **) {
|
||||
bad_unwind_info();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
// RUN: %{build}
|
||||
// RUN: %{objcopy} --dump-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
|
||||
// RUN: echo -ne '\xFF' | dd of=%t_ehf_hdr.bin bs=1 seek=2 count=2 conv=notrunc status=none
|
||||
// RUN: echo -ne '\xFF' | dd of=%t_ehf_hdr.bin bs=1 seek=2 count=2 conv=notrunc status=none
|
||||
// RUN: %{objcopy} --update-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
|
||||
// RUN: %{exec} %t.exe
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ void f() {
|
|||
assert(fde_fpc == fde_fpc1);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(int, char **) {
|
||||
f();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ __attribute__((noinline)) void foo() {
|
|||
_Unwind_Backtrace(frame_handler, NULL);
|
||||
}
|
||||
|
||||
__attribute__((section("main_func"))) int main() {
|
||||
__attribute__((section("main_func"))) int main(int, char **) {
|
||||
foo();
|
||||
return -2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ __attribute__((noinline)) void foo() {
|
|||
_Unwind_ForcedUnwind(e, stop, (void *)&foo);
|
||||
}
|
||||
|
||||
__attribute__((section("main_func"))) int main() {
|
||||
__attribute__((section("main_func"))) int main(int, char **) {
|
||||
foo();
|
||||
return -2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ __attribute__((noinline)) void test_unw_resume() {
|
|||
unw_resume(&cursor);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(int, char **) {
|
||||
test_unw_resume();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,10 @@ __attribute__((noinline)) static void foo() {
|
|||
asm volatile("" ::"vr"(v)); // Dummy inline asm to use v.
|
||||
}
|
||||
|
||||
int main() { foo(); }
|
||||
int main(int, char **) {
|
||||
foo();
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int main() { return 0; }
|
||||
int main(int, char **) { return 0; }
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue