From ee84a1290e8336eb65b7c9d80476fc466e6d18d5 Mon Sep 17 00:00:00 2001 From: Rhys-T <108157737+Rhys-T@users.noreply.github.com> Date: Thu, 2 Jan 2025 07:12:52 -0500 Subject: [PATCH] Fix build with Clang 19 - take 2 (#26) * 3rdparty/sol2: Fixed build with clang 19. sol::optional::emplace was broken, and depended on the compiler not checking that members exist if the template wasn't instantiated. See ThePHD/sol2#1606 and ThePHD/sol2#1648. Imported from upstream MAME by @Rhys-T on 2024-12-25. Original commit: https://github.com/mamedev/mame/commit/c75845b1ef01d76379bcc0a6937f1ca678484c68 * Fix Clang 18.1+ warning about variable-length arrays in C++ --- 3rdparty/sol2/sol/sol.hpp | 9 +++------ scripts/genie.lua | 5 +++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/3rdparty/sol2/sol/sol.hpp b/3rdparty/sol2/sol/sol.hpp index 9e0b5f85338..f88df707481 100644 --- a/3rdparty/sol2/sol/sol.hpp +++ b/3rdparty/sol2/sol/sol.hpp @@ -6051,12 +6051,9 @@ namespace sol { /// one. /// /// \group emplace - template - T& emplace(Args&&... args) noexcept { - static_assert(std::is_constructible::value, "T must be constructible with Args"); - - *this = nullopt; - this->construct(std::forward(args)...); + T& emplace(T& arg) noexcept { + m_value = &arg; + return **this; } /// Swaps this optional with the other. diff --git a/scripts/genie.lua b/scripts/genie.lua index a3a1ef253c8..3251171d558 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -1068,6 +1068,11 @@ end "-Wno-bitwise-instead-of-logical", -- clang 14.0 complains about &, | on bools in asmjit } end + if version >= 180100 then + buildoptions { + "-Wno-vla-cxx-extension", -- clang 18.1 complains about variable-length arrays in C++ -- HBMAME + } + end else if version < 70000 then print("GCC version 7.0 or later needed")