Skip to content

Commit 009b11b

Browse files
collisions
1 parent fbb0ca5 commit 009b11b

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

libc/test/UnitTest/LibcTest.h

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,17 @@ CString libc_make_test_file_path_func(const char *file_name);
334334
return "[ParamType = " #TYPE "]"; \
335335
}
336336

337+
#define LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA(x) _Pragma(#x);
337338

338-
#define DO_PRAGMA(x) _Pragma (#x);
339+
#define LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_BEGIN \
340+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA(GCC diagnostic push)
339341

340-
#define DO_PRAGMA_BEGIN DO_PRAGMA(GCC diagnostic push)
342+
#define LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_BODY \
343+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA(GCC diagnostic ignored \
344+
"-Wglobal-constructors")
341345

342-
#define DO_PRAGMA_BODY DO_PRAGMA(GCC diagnostic ignored "-Wglobal-constructors")
343-
344-
#define DO_PRAGMA_END DO_PRAGMA(GCC diagnostic pop)
346+
#define LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_END \
347+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA(GCC diagnostic pop)
345348

346349
#define TYPED_TEST(SuiteName, TestName, TypeList) \
347350
static_assert( \
@@ -360,11 +363,11 @@ CString libc_make_test_file_path_func(const char *file_name);
360363
void Run() override; \
361364
const char *getName() const override { return name; } \
362365
}; \
363-
DO_PRAGMA_BEGIN \
364-
DO_PRAGMA_BODY \
366+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_BEGIN \
367+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_BODY \
365368
TypeList::Tests<SuiteName##_##TestName>::type \
366369
SuiteName##_##TestName##_Instance; \
367-
DO_PRAGMA_END \
370+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_END \
368371
template <typename T> void SuiteName##_##TestName<T>::Run()
369372

370373
#define TYPED_TEST_F(SuiteClass, TestName, TypeList) \
@@ -383,11 +386,11 @@ CString libc_make_test_file_path_func(const char *file_name);
383386
void Run() override; \
384387
const char *getName() const override { return name; } \
385388
}; \
386-
DO_PRAGMA_BEGIN \
387-
DO_PRAGMA_BODY \
389+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_BEGIN \
390+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_BODY \
388391
TypeList::Tests<SuiteClass##_##TestName>::type \
389392
SuiteClass##_##TestName##_Instance; \
390-
DO_PRAGMA_END \
393+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_END \
391394
template <typename T> void SuiteClass##_##TestName<T>::Run()
392395

393396
#define TEST(SuiteName, TestName) \
@@ -399,10 +402,10 @@ CString libc_make_test_file_path_func(const char *file_name);
399402
void Run() override; \
400403
const char *getName() const override { return #SuiteName "." #TestName; } \
401404
}; \
402-
DO_PRAGMA_BEGIN \
403-
DO_PRAGMA_BODY \
405+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_BEGIN \
406+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_BODY \
404407
SuiteName##_##TestName SuiteName##_##TestName##_Instance; \
405-
DO_PRAGMA_END \
408+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_END \
406409
void SuiteName##_##TestName::Run()
407410

408411
#define TEST_F(SuiteClass, TestName) \
@@ -415,10 +418,10 @@ CString libc_make_test_file_path_func(const char *file_name);
415418
void Run() override; \
416419
const char *getName() const override { return #SuiteClass "." #TestName; } \
417420
}; \
418-
DO_PRAGMA_BEGIN \
419-
DO_PRAGMA_BODY \
421+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_BEGIN \
422+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_BODY \
420423
SuiteClass##_##TestName SuiteClass##_##TestName##_Instance; \
421-
DO_PRAGMA_END \
424+
LIBC_TEST_GLOBAL_CTOR_DO_PRAGMA_END \
422425
void SuiteClass##_##TestName::Run()
423426

424427
// Helper to trick the compiler into ignoring lack of braces on the else

0 commit comments

Comments
 (0)