@@ -334,6 +334,15 @@ CString libc_make_test_file_path_func(const char *file_name);
334334 return " [ParamType = " #TYPE " ]" ; \
335335 }
336336
337+
338+ #define DO_PRAGMA (x ) _Pragma (#x);
339+
340+ #define DO_PRAGMA_BEGIN DO_PRAGMA (GCC diagnostic push)
341+
342+ #define DO_PRAGMA_BODY DO_PRAGMA (GCC diagnostic ignored " -Wglobal-constructors" )
343+
344+ #define DO_PRAGMA_END DO_PRAGMA (GCC diagnostic pop)
345+
337346#define TYPED_TEST (SuiteName, TestName, TypeList ) \
338347 static_assert ( \
339348 LIBC_NAMESPACE::testing::internal::valid_prefix (#SuiteName), \
@@ -350,9 +359,12 @@ CString libc_make_test_file_path_func(const char *file_name);
350359 } \
351360 void Run () override ; \
352361 const char *getName () const override { return name; } \
353- static TypeList::Tests<SuiteName##_##TestName>::type \
354- SuiteName##_##TestName##_Instance; \
355362 }; \
363+ DO_PRAGMA_BEGIN \
364+ DO_PRAGMA_BODY \
365+ TypeList::Tests<SuiteName##_##TestName>::type \
366+ SuiteName##_##TestName##_Instance; \
367+ DO_PRAGMA_END \
356368 template <typename T> void SuiteName##_##TestName<T>::Run()
357369
358370#define TYPED_TEST_F (SuiteClass, TestName, TypeList ) \
@@ -370,9 +382,12 @@ CString libc_make_test_file_path_func(const char *file_name);
370382 } \
371383 void Run () override ; \
372384 const char *getName () const override { return name; } \
373- static TypeList::Tests<SuiteClass##_##TestName>::type \
374- SuiteClass##_##TestName##_Instance; \
375385 }; \
386+ DO_PRAGMA_BEGIN \
387+ DO_PRAGMA_BODY \
388+ TypeList::Tests<SuiteClass##_##TestName>::type \
389+ SuiteClass##_##TestName##_Instance; \
390+ DO_PRAGMA_END \
376391 template <typename T> void SuiteClass##_##TestName<T>::Run()
377392
378393#define TEST (SuiteName, TestName ) \
@@ -383,8 +398,11 @@ CString libc_make_test_file_path_func(const char *file_name);
383398 SuiteName##_##TestName() { addTest (this ); } \
384399 void Run () override ; \
385400 const char *getName () const override { return #SuiteName " ." #TestName; } \
386- static SuiteName##_##TestName SuiteName##_##TestName##_Instance; \
387401 }; \
402+ DO_PRAGMA_BEGIN \
403+ DO_PRAGMA_BODY \
404+ SuiteName##_##TestName SuiteName##_##TestName##_Instance; \
405+ DO_PRAGMA_END \
388406 void SuiteName##_##TestName::Run()
389407
390408#define TEST_F (SuiteClass, TestName ) \
@@ -396,8 +414,11 @@ CString libc_make_test_file_path_func(const char *file_name);
396414 SuiteClass##_##TestName() { addTest (this ); } \
397415 void Run () override ; \
398416 const char *getName () const override { return #SuiteClass " ." #TestName; } \
399- static SuiteClass##_##TestName SuiteClass##_##TestName##_Instance; \
400417 }; \
418+ DO_PRAGMA_BEGIN \
419+ DO_PRAGMA_BODY \
420+ SuiteClass##_##TestName SuiteClass##_##TestName##_Instance; \
421+ DO_PRAGMA_END \
401422 void SuiteClass##_##TestName::Run()
402423
403424// Helper to trick the compiler into ignoring lack of braces on the else
0 commit comments