diff options
author | Marek Polacek <polacek@redhat.com> | 2018-08-21 15:25:17 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2018-08-21 15:25:17 +0000 |
commit | 992931ba3d02d107b3abf51781b4b4625d2cce7c (patch) | |
tree | 671d641b6208764e364a009dbd4bbc0ae066d46b /gcc/cp | |
parent | d3e993e9b0774326a86836924eff2ddd3511d4a2 (diff) | |
download | gcc-992931ba3d02d107b3abf51781b4b4625d2cce7c.zip gcc-992931ba3d02d107b3abf51781b4b4625d2cce7c.tar.gz gcc-992931ba3d02d107b3abf51781b4b4625d2cce7c.tar.bz2 |
re PR c++/65043 (Expected narrowing conversion during list initialization of bool from double)
PR c++/65043
* call.c (standard_conversion): Set check_narrowing.
* typeck2.c (check_narrowing): Use CP_INTEGRAL_TYPE_P rather
than comparing with INTEGER_TYPE.
* g++.dg/concepts/pr67595.C: Add dg-warning.
* g++.dg/cpp0x/Wnarrowing11.C: New test.
* g++.dg/cpp0x/Wnarrowing12.C: New test.
* g++.dg/cpp0x/rv-cast5.C: Add static_cast.
From-SVN: r263739
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/call.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 2 |
3 files changed, 8 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fc1b255..44be980 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2018-08-21 Marek Polacek <polacek@redhat.com> + PR c++/65043 + * call.c (standard_conversion): Set check_narrowing. + * typeck2.c (check_narrowing): Use CP_INTEGRAL_TYPE_P rather + than comparing with INTEGER_TYPE. + * cp-tree.h: Fix typo. 2018-08-20 David Malcolm <dmalcolm@redhat.com> diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 1f72ac8..626830c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1388,6 +1388,8 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, conv->rank = cr_pbool; if (NULLPTR_TYPE_P (from) && (flags & LOOKUP_ONLYCONVERTING)) conv->bad_p = true; + if (flags & LOOKUP_NO_NARROWING) + conv->check_narrowing = true; return conv; } diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index f42f0c2..1e899ab 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -913,7 +913,7 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain, bool const_only) if (const_only && !TREE_CONSTANT (init)) return ok; - if (TREE_CODE (type) == INTEGER_TYPE + if (CP_INTEGRAL_TYPE_P (type) && TREE_CODE (ftype) == REAL_TYPE) ok = false; else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype) |