Skip to content

Commit e8be053

Browse files
pragma wrap
1 parent 620bf4a commit e8be053

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

libc/test/UnitTest/LibcTest.h

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

337-
#pragma GCC diagnostic push
338-
#pragma GCC diagnostic ignored "-Wglobal-constructors"
337+
#define DO_PRAGMA_BEGIN #pragma GCC diagnostic push
338+
339+
#define DO_PRAGMA #pragma GCC diagnostic ignored "-Wglobal-constructors"
340+
341+
#define DO_PRAGMA_END #pragma GCC diagnostic pop
339342

340343
#define TYPED_TEST(SuiteName, TestName, TypeList) \
341344
static_assert( \
@@ -354,8 +357,11 @@ CString libc_make_test_file_path_func(const char *file_name);
354357
void Run() override; \
355358
const char *getName() const override { return name; } \
356359
}; \
360+
DO_PRAGMA_BEGIN \
361+
DO_PRAGMA \
357362
TypeList::Tests<SuiteName##_##TestName>::type \
358363
SuiteName##_##TestName##_Instance; \
364+
DO_PRAGMA_END \
359365
template <typename T> void SuiteName##_##TestName<T>::Run()
360366

361367
#define TYPED_TEST_F(SuiteClass, TestName, TypeList) \
@@ -374,8 +380,11 @@ CString libc_make_test_file_path_func(const char *file_name);
374380
void Run() override; \
375381
const char *getName() const override { return name; } \
376382
}; \
383+
DO_PRAGMA_BEGIN \
384+
DO_PRAGMA \
377385
TypeList::Tests<SuiteClass##_##TestName>::type \
378386
SuiteClass##_##TestName##_Instance; \
387+
DO_PRAGMA_END \
379388
template <typename T> void SuiteClass##_##TestName<T>::Run()
380389

381390
#define TEST(SuiteName, TestName) \
@@ -387,7 +396,10 @@ CString libc_make_test_file_path_func(const char *file_name);
387396
void Run() override; \
388397
const char *getName() const override { return #SuiteName "." #TestName; } \
389398
}; \
399+
DO_PRAGMA_BEGIN \
400+
DO_PRAGMA \
390401
SuiteName##_##TestName SuiteName##_##TestName##_Instance; \
402+
DO_PRAGMA_END \
391403
void SuiteName##_##TestName::Run()
392404

393405
#define TEST_F(SuiteClass, TestName) \
@@ -400,11 +412,12 @@ CString libc_make_test_file_path_func(const char *file_name);
400412
void Run() override; \
401413
const char *getName() const override { return #SuiteClass "." #TestName; } \
402414
}; \
415+
DO_PRAGMA_BEGIN \
416+
DO_PRAGMA \
403417
SuiteClass##_##TestName SuiteClass##_##TestName##_Instance; \
418+
DO_PRAGMA_END \
404419
void SuiteClass##_##TestName::Run()
405420

406-
#pragma GCC diagnostic pop
407-
408421
// Helper to trick the compiler into ignoring lack of braces on the else
409422
// branch. We cannot introduce braces at this point, since it would prevent
410423
// using `<< ...` after the test macro for additional failure output.

0 commit comments

Comments
 (0)