[libc-commits] [libc] [libc][test] Avoid missing field initializers in time tests (PR #239675)
Jeff Bailey via libc-commits
libc-commits at lists.llvm.org
Fri Nov 6 08:50:20 PST 2026
https://github.com/kaladron created https://github.com/llvm/llvm-project/pull/239675
In full-build mode on Linux, struct tm includes the tm_gmtoff and tm_zone extension fields. Under -Wmissing-field-initializers (promoted to error by LLVM builds), Clang warns when struct tm is initialised using aggregate or designated initialisers that omit these extension fields, causing compilation failures in time unit tests.
Disable -Wmissing-field-initializers across the affected time tests in CMakeLists.txt so designated and aggregate initialisers can omit fields per standard value-initialisation rules.
Assisted-by: Automated tooling, human reviewed.
>From 9072b6324f9f89897cb33841f4d38818965aede4 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Fri, 6 Nov 2026 08:34:50 +0000
Subject: [PATCH] [libc][test] Avoid missing field initializers in time tests
In full-build mode on Linux, struct tm includes the tm_gmtoff and
tm_zone extension fields. Under -Wmissing-field-initializers (promoted
to error by LLVM builds), Clang warns when struct tm is initialised
using aggregate or designated initialisers that omit these extension
fields, causing compilation failures in time unit tests.
Disable -Wmissing-field-initializers across the affected time tests in
CMakeLists.txt so designated and aggregate initialisers can omit fields
per standard value-initialisation rules.
Assisted-by: Automated tooling, human reviewed.
---
libc/test/src/time/CMakeLists.txt | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/libc/test/src/time/CMakeLists.txt b/libc/test/src/time/CMakeLists.txt
index 037394f8741775..d31e90f9a5b4de 100644
--- a/libc/test/src/time/CMakeLists.txt
+++ b/libc/test/src/time/CMakeLists.txt
@@ -1,5 +1,10 @@
add_libc_testsuite(libc-time-tests)
+# Allow designated and aggregate initialisers of struct tm to omit fields
+# (such as platform extension fields tm_gmtoff and tm_zone) and rely on
+# standard zero-initialisation without compiler warnings.
+set(time_test_copts "-Wno-missing-field-initializers")
+
add_header_library(
time_test_utils
HDRS
@@ -20,6 +25,8 @@ add_libc_test(
asctime_test.cpp
CXX_STANDARD
20
+ COMPILE_OPTIONS
+ ${time_test_copts}
DEPENDS
.time_test_utils
libc.hdr.errno_macros
@@ -37,6 +44,8 @@ add_libc_test(
asctime_r_test.cpp
CXX_STANDARD
20
+ COMPILE_OPTIONS
+ ${time_test_copts}
DEPENDS
.time_test_utils
libc.hdr.errno_macros
@@ -54,6 +63,8 @@ add_libc_test(
ctime_test.cpp
CXX_STANDARD
20
+ COMPILE_OPTIONS
+ ${time_test_copts}
DEPENDS
.time_test_utils
libc.include.time
@@ -72,6 +83,8 @@ add_libc_test(
ctime_r_test.cpp
CXX_STANDARD
20
+ COMPILE_OPTIONS
+ ${time_test_copts}
DEPENDS
.time_test_utils
libc.include.time
@@ -205,6 +218,8 @@ add_libc_test(
libc-time-tests
SRCS
gmtime_test.cpp
+ COMPILE_OPTIONS
+ ${time_test_copts}
DEPENDS
.time_test_utils
libc.hdr.errno_macros
@@ -222,6 +237,8 @@ add_libc_test(
libc-time-tests
SRCS
gmtime_r_test.cpp
+ COMPILE_OPTIONS
+ ${time_test_copts}
DEPENDS
.time_test_utils
libc.src.time.gmtime_r
@@ -238,6 +255,8 @@ add_libc_test(
mktime_test.cpp
CXX_STANDARD
20
+ COMPILE_OPTIONS
+ ${time_test_copts}
DEPENDS
.time_test_utils
libc.src.time.mktime
More information about the libc-commits
mailing list