diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -74,12 +74,12 @@ jobs: matrix: include: - name: Clang - Debug - compiler: clang - cxxcompiler: clang++ + compiler: clang-15 + cxxcompiler: clang++-15 libraries: libsdl2-dev - name: Clang - Release - compiler: clang - cxxcompiler: clang++ + compiler: clang-15 + cxxcompiler: clang++-15 libraries: libsdl2-dev extra-cmake-parameters: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPTION_USE_ASSERTS=OFF - name: GCC - SDL2 diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ set_directory_options() include(Static) set_static_if_needed() -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_CXX_EXTENSIONS NO) diff --git a/src/blitter/32bpp_anim_sse4.cpp b/src/blitter/32bpp_anim_sse4.cpp --- a/src/blitter/32bpp_anim_sse4.cpp +++ b/src/blitter/32bpp_anim_sse4.cpp @@ -31,7 +31,7 @@ static FBlitter_32bppSSE4_Anim iFBlitter IGNORE_UNINITIALIZED_WARNING_START template GNU_TARGET("sse4.1") -inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom) +inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom) { const byte * const remap = bp->remap; Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left; diff --git a/src/direction_func.h b/src/direction_func.h --- a/src/direction_func.h +++ b/src/direction_func.h @@ -71,7 +71,7 @@ inline DirDiff DirDifference(Direction d assert(IsValidDirection(d1)); /* Cast to uint so compiler can use bitmask. If the difference is negative * and we used int instead of uint, further "+ 8" would have to be added. */ - return (DirDiff)((uint)(d0 - d1) % 8); + return static_cast(static_cast(d0) - static_cast(d1) % 8); } /** @@ -88,7 +88,7 @@ inline DirDiff DirDifference(Direction d inline DirDiff ChangeDirDiff(DirDiff d, DirDiff delta) { /* Cast to uint so compiler can use bitmask. Result can never be negative. */ - return (DirDiff)((uint)(d + delta) % 8); + return static_cast((static_cast(d) + static_cast(delta)) % 8); } /** @@ -105,7 +105,7 @@ inline Direction ChangeDir(Direction d, { assert(IsValidDirection(d)); /* Cast to uint so compiler can use bitmask. Result can never be negative. */ - return (Direction)((uint)(d + delta) % 8); + return static_cast((static_cast(d) + static_cast(delta)) % 8); } @@ -150,7 +150,7 @@ inline DiagDirection ChangeDiagDir(DiagD { assert(IsValidDiagDirection(d)); /* Cast to uint so compiler can use bitmask. Result can never be negative. */ - return (DiagDirection)((uint)(d + delta) % 4); + return static_cast((static_cast(d) + static_cast(delta)) % 4); } /** diff --git a/src/fileio_type.h b/src/fileio_type.h --- a/src/fileio_type.h +++ b/src/fileio_type.h @@ -89,7 +89,7 @@ enum FiosType { */ inline AbstractFileType GetAbstractFileType(FiosType fios_type) { - return static_cast(fios_type & FT_MASK); + return static_cast(static_cast(fios_type) & FT_MASK); } /** diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp --- a/src/script/api/script_rail.cpp +++ b/src/script/api/script_rail.cpp @@ -250,7 +250,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, ::IsValidTile(tile)); EnforcePrecondition(false, rail_track != 0); - EnforcePrecondition(false, (rail_track & ~::TRACK_BIT_ALL) == 0); + EnforcePrecondition(false, (static_cast(rail_track) & ~static_cast(::TRACK_BIT_ALL)) == 0); EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0); EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType())); diff --git a/src/script/api/script_station.cpp b/src/script/api/script_station.cpp --- a/src/script/api/script_station.cpp +++ b/src/script/api/script_station.cpp @@ -203,7 +203,7 @@ template if (!IsValidStation(station_id)) return false; if (!HasExactlyOneBit(station_type)) return false; - return (::Station::Get(station_id)->facilities & station_type) != 0; + return (::Station::Get(station_id)->facilities & static_cast(station_type)) != 0; } /* static */ bool ScriptStation::HasRoadType(StationID station_id, ScriptRoad::RoadType road_type) diff --git a/src/script/api/script_stationlist.cpp b/src/script/api/script_stationlist.cpp --- a/src/script/api/script_stationlist.cpp +++ b/src/script/api/script_stationlist.cpp @@ -23,7 +23,7 @@ ScriptStationList::ScriptStationList(Scr CompanyID owner = ScriptObject::GetCompany(); ScriptList::FillList(this, [is_deity, owner, station_type](const Station *st) { - return (is_deity || st->owner == owner) && (st->facilities & station_type) != 0; + return (is_deity || st->owner == owner) && (st->facilities & static_cast(station_type)) != 0; } ); } diff --git a/src/script/api/script_waypoint.cpp b/src/script/api/script_waypoint.cpp --- a/src/script/api/script_waypoint.cpp +++ b/src/script/api/script_waypoint.cpp @@ -34,5 +34,5 @@ if (!IsValidWaypoint(waypoint_id)) return false; if (!HasExactlyOneBit(waypoint_type)) return false; - return (::Waypoint::Get(waypoint_id)->facilities & waypoint_type) != 0; + return (::Waypoint::Get(waypoint_id)->facilities & static_cast(waypoint_type)) != 0; } diff --git a/src/script/api/script_waypointlist.cpp b/src/script/api/script_waypointlist.cpp --- a/src/script/api/script_waypointlist.cpp +++ b/src/script/api/script_waypointlist.cpp @@ -23,7 +23,7 @@ ScriptWaypointList::ScriptWaypointList(S CompanyID owner = ScriptObject::GetCompany(); ScriptList::FillList(this, [is_deity, owner, waypoint_type](const Waypoint *wp) { - return (is_deity || wp->owner == owner || wp->owner == OWNER_NONE) && (wp->facilities & waypoint_type) != 0; + return (is_deity || wp->owner == owner || wp->owner == OWNER_NONE) && (wp->facilities & static_cast(waypoint_type)) != 0; } ); } diff --git a/src/slope_func.h b/src/slope_func.h --- a/src/slope_func.h +++ b/src/slope_func.h @@ -391,7 +391,7 @@ inline Foundation InclinedFoundation(Axi inline Foundation HalftileFoundation(Corner corner) { assert(IsValidCorner(corner)); - return (Foundation)(FOUNDATION_HALFTILE_W + corner); + return static_cast(static_cast(FOUNDATION_HALFTILE_W) + static_cast(corner)); } /** @@ -403,7 +403,7 @@ inline Foundation HalftileFoundation(Cor inline Foundation SpecialRailFoundation(Corner corner) { assert(IsValidCorner(corner)); - return (Foundation)(FOUNDATION_RAIL_W + corner); + return static_cast(static_cast(FOUNDATION_RAIL_W) + static_cast(corner)); } /**