Remove constexpr from a function that doesn't need it, and asserts

The call to q_assert() isn't constexpr, so can't happen in a constexpr
function. Most compilers shrug this off as they can see the code
actually is unreachable, but apparently debug builds on QNX can't work
that out. Since nothing actually needs the function to be constexpr,
remove that qualifier. In the process, move the offset-case, which is
also unreachable, to the end of the switch, closer to the unreachable
end of the function (since I failed to spot that there were two
unreachable parts at first).

Fixes: QTBUG-132698
Change-Id: Ibdde7abd91d284e1c1af53e2b5e142fc234400a8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 2578d72a7cb9b784a00efb04df6a31496d92dcdc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit cf9e8434eb1d6cb527f8f216c4c37c14cf713690)
This commit is contained in:
Edward Welbourne 2025-01-09 14:02:38 +01:00 committed by Qt Cherry-pick Bot
parent 500983b29c
commit 815ca48654

View File

@ -17,19 +17,19 @@ QT_BEGIN_NAMESPACE
namespace { namespace {
// Convert TimeType and NameType into ICU UCalendarDisplayNameType // Convert TimeType and NameType into ICU UCalendarDisplayNameType
constexpr UCalendarDisplayNameType ucalDisplayNameType(QTimeZone::TimeType timeType, UCalendarDisplayNameType ucalDisplayNameType(QTimeZone::TimeType timeType,
QTimeZone::NameType nameType) QTimeZone::NameType nameType)
{ {
// TODO ICU C UCalendarDisplayNameType does not support full set of C++ TimeZone::EDisplayType // TODO ICU C UCalendarDisplayNameType does not support full set of C++ TimeZone::EDisplayType
// For now, treat Generic as Standard // For now, treat Generic as Standard
switch (nameType) { switch (nameType) {
case QTimeZone::OffsetName:
Q_UNREACHABLE(); // Callers of ucalTimeZoneDisplayName() should take care of OffsetName.
case QTimeZone::ShortName: case QTimeZone::ShortName:
return timeType == QTimeZone::DaylightTime ? UCAL_SHORT_DST : UCAL_SHORT_STANDARD; return timeType == QTimeZone::DaylightTime ? UCAL_SHORT_DST : UCAL_SHORT_STANDARD;
case QTimeZone::DefaultName: case QTimeZone::DefaultName:
case QTimeZone::LongName: case QTimeZone::LongName:
return timeType == QTimeZone::DaylightTime ? UCAL_DST : UCAL_STANDARD; return timeType == QTimeZone::DaylightTime ? UCAL_DST : UCAL_STANDARD;
case QTimeZone::OffsetName:
Q_UNREACHABLE(); // Callers of ucalTimeZoneDisplayName() should take care of OffsetName.
} }
Q_UNREACHABLE_RETURN(UCAL_STANDARD); Q_UNREACHABLE_RETURN(UCAL_STANDARD);
} }