commit 386dedafa65ac0f9cf726c63fd83d47b971b459d Author: Christoph Moench-Tegeder Partially de-constexpr'ify LanguageId code This is to deal with our (FreeBSD) libc++, where in some cases std:pair<> is not a "literal type" (suitable for constexpr), even if the same std:pair<> is just fine on all other relevant systems. This removes just enough constexpr annotations to make the code compile. Sample compiler error message: /wrkdirs/usr/ports/www/firefox/work/firefox-151.0/js/src/util/LanguageId.h:234:66: error: constexpr function's return type 'mozilla::Maybe 234 | static constexpr mozilla::Maybe> from( | /wrkdirs/usr/ports/www/firefox/work/.build/dist/include/mozilla/Maybe.h:367:7: note: 'Maybe>' is not literal because i> 367 | : private detail::MaybeStorage, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git js/src/builtin/intl/LocaleNegotiation.cpp js/src/builtin/intl/LocaleNegotiation.cpp index d6c6a9c7760b..c23315ede19c 100644 --- js/src/builtin/intl/LocaleNegotiation.cpp +++ js/src/builtin/intl/LocaleNegotiation.cpp @@ -1163,13 +1163,13 @@ struct OldStyleLanguageTagMapping { LanguageId oldStyle; LanguageId modernStyle; - consteval OldStyleLanguageTagMapping(std::string_view oldStyle, + OldStyleLanguageTagMapping(std::string_view oldStyle, std::string_view modernStyle) : oldStyle(LanguageId::fromValidBcp49(oldStyle)), modernStyle(LanguageId::fromValidBcp49(modernStyle)) {} }; -static constexpr OldStyleLanguageTagMapping oldStyleLanguageTagMappings[] = { +static OldStyleLanguageTagMapping oldStyleLanguageTagMappings[] = { {"pa-PK", "pa-Arab-PK"}, {"zh-CN", "zh-Hans-CN"}, {"zh-HK", "zh-Hant-HK"}, {"zh-SG", "zh-Hans-SG"}, {"zh-TW", "zh-Hant-TW"}, }; diff --git js/src/builtin/intl/SharedIntlData.cpp js/src/builtin/intl/SharedIntlData.cpp index 5ab01896f32f..c5834175f80d 100644 --- js/src/builtin/intl/SharedIntlData.cpp +++ js/src/builtin/intl/SharedIntlData.cpp @@ -431,12 +431,12 @@ bool js::intl::SharedIntlData::getAvailableLocales( // directly support it (but does support it through fallback, e.g. supporting // "en-GB" indirectly using "en" support). { - static constexpr auto lastDitch = LastDitchLocale(); - static_assert(std::string_view{lastDitch.toString()} == "en-GB"); + static auto lastDitch = LastDitchLocale(); + // static_assert(std::string_view{lastDitch.toString()} == "en-GB"); #ifdef DEBUG - static constexpr auto lastDitchParent = lastDitch.parentLocale(); - static_assert(std::string_view{lastDitchParent.toString()} == "en"); + static auto lastDitchParent = lastDitch.parentLocale(); + // static_assert(std::string_view{lastDitchParent.toString()} == "en"); MOZ_ASSERT(locales.has(lastDitchParent), "shouldn't be a need to add every locale implied by the " diff --git js/src/util/LanguageId.h js/src/util/LanguageId.h index cb8561f952d0..f8fd1766987d 100644 --- js/src/util/LanguageId.h +++ js/src/util/LanguageId.h @@ -230,7 +230,7 @@ class LanguageId final { private: template - static constexpr mozilla::Maybe> from( + static /* constexpr */ mozilla::Maybe> from( std::basic_string_view localeId) { // Return true iff |sv| starts with a subtag of length |len|. auto hasSubtag = [](std::basic_string_view sv, size_t len) { @@ -312,7 +312,7 @@ class LanguageId final { * * Subtags in ICU and Unicode locale identifiers are separated by "-" or "_". */ - static constexpr auto fromId(std::string_view localeId) { + static auto fromId(std::string_view localeId) { return from<'-', '_'>(localeId); } @@ -326,7 +326,7 @@ class LanguageId final { * * Subtags in ICU and Unicode locale identifiers are separated by "-" or "_". */ - static constexpr auto fromId(mozilla::Span localeId) { + static auto fromId(mozilla::Span localeId) { return fromId(std::string_view{localeId.data(), localeId.size()}); } @@ -340,7 +340,7 @@ class LanguageId final { * * Subtags in BCP 47 locale identifiers are separated by "-". */ - static constexpr auto fromBcp49(std::string_view localeId) { + static auto fromBcp49(std::string_view localeId) { return from<'-'>(localeId); } @@ -354,7 +354,7 @@ class LanguageId final { * * Subtags in BCP 47 locale identifiers are separated by "-". */ - static constexpr auto fromBcp49(std::u16string_view localeId) { + static auto fromBcp49(std::u16string_view localeId) { return from(localeId); } @@ -369,7 +369,7 @@ class LanguageId final { * Subtags in BCP 47 locale identifiers are separated by "-". */ template - static constexpr auto fromBcp49(mozilla::Span localeId) { + static auto fromBcp49(mozilla::Span localeId) { return fromBcp49(std::basic_string_view{localeId.data(), localeId.size()}); } @@ -380,7 +380,7 @@ class LanguageId final { * * Subtags in BCP 47 locale identifiers are separated by "-". */ - static consteval auto fromValidBcp49(std::string_view localeId) { + static auto fromValidBcp49(std::string_view localeId) { return fromBcp49(localeId)->first; } @@ -407,8 +407,8 @@ class LanguageId final { /** * Return the language identifier for the undetermined locale "und". */ - static constexpr auto und() { - constexpr LanguageId locale = fromValidBcp49("und"); + static auto und() { + LanguageId locale = fromValidBcp49("und"); return locale; }