From 8b0e068847c03c58f510f89c85dcc7a5e4ac7ef4 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 9 Oct 2020 12:26:19 +0200 Subject: [PATCH] Mark QLocale's Language, Country and Script enums as ushort MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code pervasively presumes their values can be held in a ushort, so make sure the compiler knows we expect that to work (and doesn't complain about narrowing when we do convert them to ushort). Change-Id: Idde7be6cceee8a6dae333c5b1d5a0120fec32e4a Reviewed-by: Andrei Golubev Reviewed-by: MÃ¥rten Nordheim --- src/corelib/text/qlocale.h | 6 +++--- util/locale_database/qlocalexml2cpp.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/text/qlocale.h b/src/corelib/text/qlocale.h index 8b49eb89f9b..bb96f45c5fe 100644 --- a/src/corelib/text/qlocale.h +++ b/src/corelib/text/qlocale.h @@ -74,7 +74,7 @@ class Q_CORE_EXPORT QLocale public: // see qlocale_data_p.h for more info on generated data // GENERATED PART STARTS HERE - enum Language { + enum Language : ushort { AnyLanguage = 0, C = 1, Abkhazian = 2, @@ -464,7 +464,7 @@ public: LastLanguage = Silesian }; - enum Script { + enum Script : ushort { AnyScript = 0, ArabicScript = 1, CyrillicScript = 2, @@ -614,7 +614,7 @@ public: LastScript = JamoScript }; - enum Country { + enum Country : ushort { AnyCountry = 0, Afghanistan = 1, Albania = 2, diff --git a/util/locale_database/qlocalexml2cpp.py b/util/locale_database/qlocalexml2cpp.py index 4235f1feb3a..bf4d5802367 100755 --- a/util/locale_database/qlocalexml2cpp.py +++ b/util/locale_database/qlocalexml2cpp.py @@ -468,7 +468,7 @@ class LocaleHeaderWriter (SourceFileEditor): def __enum(self, name, book, alias): assert book out, dupes = self.writer.write, self.__dupes - out(' enum {} {{\n'.format(name)) + out(' enum {} : ushort {{\n'.format(name)) for key, value in book.items(): member = value[0] if name == 'Script':