diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 02b1755bf8..71aa35dc94 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -86,6 +86,8 @@ line upon naming the release. Refer to previous for appropriate section names. - Fixed members following a merged bitfield reading the wrong value when a struct is flat-converted [#8526](https://github.com/microsoft/DirectXShaderCompiler/issues/8526). +- Fixed a C++26 compilation error in `llvm::sys::TimeValue` due to arithmetic on unscoped enumeration `NANOSECONDS_PER_SECOND` + [#8992](https://github.com/microsoft/DirectXShaderCompiler/issues/8992). ### Upcoming Preview Release diff --git a/include/llvm/Support/TimeValue.h b/include/llvm/Support/TimeValue.h index 6bca58b6bc..1e23644cd5 100644 --- a/include/llvm/Support/TimeValue.h +++ b/include/llvm/Support/TimeValue.h @@ -107,8 +107,9 @@ namespace sys { : seconds_( 0 ) , nanos_ ( 0 ) { SecondsType integer_part = static_cast( new_time ); seconds_ = integer_part; - nanos_ = static_cast( (new_time - - static_cast(integer_part)) * NANOSECONDS_PER_SECOND ); + nanos_ = static_cast( + (new_time - static_cast(integer_part)) * + static_cast(NANOSECONDS_PER_SECOND)); this->normalize(); } diff --git a/unittests/Support/TimeValueTest.cpp b/unittests/Support/TimeValueTest.cpp index 3d2b9780c0..c10bbba114 100644 --- a/unittests/Support/TimeValueTest.cpp +++ b/unittests/Support/TimeValueTest.cpp @@ -37,4 +37,9 @@ TEST(TimeValue, Win32FILETIME) { EXPECT_EQ(ft1970, epoch.toWin32Time()); } +TEST(TimeValue, DoubleConstructor) { + sys::TimeValue tv(1234.5); + EXPECT_EQ(1234, tv.seconds()); + EXPECT_EQ(500000000u, static_cast(tv.nanoseconds())); +} }