qt5base-lts/tests/auto/corelib
Giuseppe D'Angelo bb0a616260 QObject: overhaul narrowing detection
Use P0608's trick to detect convertibility without narrowing;
and now that we can depend on C++17, use its features.

First, this moves the burden of detecting a narrowing conversion on
the compiler, rather than us maintaining a complicated series
of checks. Of course, this exposes

* bugs in compilers (e.g. GCC < 9 thinks that float->bool is not
  narrowing;

* behavior still not (widely) implemented (pointer to bool
  conversions are narrowing, P1957);

* interesting compiler choices, e.g. GCC 9 thinks that unscoped
  enumerations are non-narrowing convertible to a datatype big
  enum to contain all the _enumerators_, even if the underlying
  type of the enum (and/or its sizeof()) is wider than the target
  datatype.

Second, it allows to detect conversions that have a narrowing
conversion as an intermediate step. Given a type like

  struct Bad { operator double() const; };

then an object of type Bad is implictly convertible to a type
like int via a narrowing conversion. Therefore, a connection
is possible between a signal carrying a Bad and a slot accepting
an int. We can now detect and block this.

Tests regarding scoped enumerations have been dropped,
for the simple reason that a scoped enumeration is not
implictly convertible to an integral type, so we don't have
that detection (it would constantly fail). Scoped enumerations
do not take part in narrowing conversions anyhow, cf. [dcl.init.list].

[ChangeLog][QtCore][QObject] The detection of narrowing conversions
when calling QObject::connect() when
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT now takes also
into account user-defined implicit conversions that undergo
through a narrowing conversion.

Change-Id: Ie09d59203fe6283378b36dfbc54de1d58098ef51
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-04-15 15:20:45 +02:00
..
animation Merge remote-tracking branch 'origin/5.15' into dev 2020-03-16 18:41:27 +01:00
codecs Regenerate tests/auto/corelib/codecs 2019-11-12 17:26:41 +00:00
global Merge remote-tracking branch 'origin/5.15' into dev 2020-04-08 20:11:39 +02:00
io Port test over to use QRegularExpression 2020-04-13 09:40:38 +02:00
itemmodels Remove QRegExp support from QSortFilterProxyModel 2020-04-15 14:38:40 +02:00
kernel QObject: overhaul narrowing detection 2020-04-15 15:20:45 +02:00
mimetypes QtConcurrent::run: accept more then five function's arguments 2020-03-11 14:46:25 +01:00
plugin Change qHash() to work with size_t instead of uint 2020-04-09 20:03:25 +02:00
serialization Merge remote-tracking branch 'origin/5.15' into dev 2020-04-11 14:59:13 +02:00
statemachine Merge remote-tracking branch 'origin/5.15' into dev 2020-02-13 18:31:40 +01:00
text Merge remote-tracking branch 'origin/5.15' into dev 2020-04-08 20:11:39 +02:00
thread Add support of failure handler callbacks to QFuture 2020-04-01 21:51:13 +02:00
time Make QLocale(QString) explicit 2020-04-01 09:29:26 +01:00
tools Change qHashBits to use MurmurHash2 2020-04-09 20:03:45 +02:00
.prev_CMakeLists.txt cmake: Remove APPLE prefix from platform names 2020-03-16 17:57:56 +01:00
CMakeLists.txt cmake: Remove APPLE prefix from platform names 2020-03-16 17:57:56 +01:00
corelib.pro Move text-related code out of corelib/tools/ to corelib/text/ 2019-07-10 17:05:30 +02:00