diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-06-09 14:46:01 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-07-03 16:01:07 +0000 |
commit | fb046c932f0d1c54a2baf3633de26926c939082b (patch) | |
tree | 5814260c5d70589a287033a9c7bca988d5f41a2f /src | |
parent | d3590d32a53c90fec6596bd8f443c8a6f55d2bef (diff) |
Fix build with MSVC 2015 Update 2 if constexpr is enabled
This compiler seems to require explicit initialization of all member
variables in a constexpr constructor, even if they have an implicit
default constructor of their own. We probably fixed the rest of Qt a
couple of years ago, but not these two places because they were arrays
and those require the C++11 syntax for uniform initialization.
All compilers that support constexpr do support uniform initialization.
MSVC 2015 fixed our issues with it on the same update.
Change-Id: Ibc1eb23e3ae093f5c6928ded3a041be35eb9baae
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qfreelist_p.h | 6 | ||||
-rw-r--r-- | src/widgets/widgets/qcalendarwidget.cpp | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index a8d1132d06..2f98cf5cc1 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -207,7 +207,11 @@ public: template <typename T, typename ConstantsType> Q_DECL_CONSTEXPR inline QFreeList<T, ConstantsType>::QFreeList() - : _next(ConstantsType::InitialNextValue) + : +#if defined(Q_COMPILER_CONSTEXPR) + _v{}, // uniform initialization required +#endif + _next(ConstantsType::InitialNextValue) { } template <typename T, typename ConstantsType> diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index c5db3a7c9a..b96492d623 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -832,7 +832,12 @@ class StaticDayOfWeekAssociativeArray { static Q_DECL_CONSTEXPR int day2idx(Qt::DayOfWeek day) Q_DECL_NOTHROW { return int(day) - 1; } // alt: day % 7 public: Q_DECL_CONSTEXPR StaticDayOfWeekAssociativeArray() Q_DECL_NOEXCEPT_EXPR(noexcept(T())) - : contained(), data() {} +#ifdef Q_COMPILER_CONSTEXPR + : contained{}, data{} // arrays require uniform initialization +#else + : contained(), data() +#endif + {} Q_DECL_CONSTEXPR bool contains(Qt::DayOfWeek day) const Q_DECL_NOTHROW { return contained[day2idx(day)]; } Q_DECL_CONSTEXPR const T &value(Qt::DayOfWeek day) const Q_DECL_NOTHROW { return data[day2idx(day)]; } |