diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-06-03 17:48:36 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-06-03 17:48:36 +0000 |
commit | d7f56aae6075e90d4697eae5a952ab31124a4a65 (patch) | |
tree | 54b27c0d7522595986d603e6ad8e917772e53451 /gcc/cp/call.c | |
parent | c69ec07da595081a3bc476bebe4729049b6254d8 (diff) | |
download | gcc-d7f56aae6075e90d4697eae5a952ab31124a4a65.tar.gz |
gcc/cp
2014-06-03 Paolo Carlini <paolo.carlini@oracle.com>
DR 1423
PR c++/52174
* call.c (standard_conversion): Convert nullptr to bool only
in case of direct-initialization.
(convert_like_real): Provide informative error message.
gcc/testsuite
2014-06-03 Paolo Carlini <paolo.carlini@oracle.com>
DR 1423
PR c++/52174
* g++.dg/cpp0x/nullptr31.C: New.
* g++.dg/cpp0x/sfinae-nullptr1.C: Likewise.
* g++.dg/cpp0x/nullptr17.C: Update.
libstdc++-v3
2014-06-03 Paolo Carlini <paolo.carlini@oracle.com>
DR 1423
PR c++/52174
* testsuite/20_util/is_assignable/value.cc: Update.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211195 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r-- | gcc/cp/call.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index b60bab775cd..75a6a4acc29 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1311,10 +1311,10 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, { /* [conv.bool] - An rvalue of arithmetic, unscoped enumeration, pointer, or - pointer to member type can be converted to an rvalue of type - bool. ... An rvalue of type std::nullptr_t can be converted - to an rvalue of type bool; */ + A prvalue of arithmetic, unscoped enumeration, pointer, or pointer + to member type can be converted to a prvalue of type bool. ... + For direct-initialization (8.5 [dcl.init]), a prvalue of type + std::nullptr_t can be converted to a prvalue of type bool; */ if (ARITHMETIC_TYPE_P (from) || UNSCOPED_ENUM_P (from) || fcode == POINTER_TYPE @@ -1328,6 +1328,8 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, && conv->rank < cr_pbool) || NULLPTR_TYPE_P (from)) conv->rank = cr_pbool; + if (NULLPTR_TYPE_P (from) && (flags & LOOKUP_ONLYCONVERTING)) + conv->bad_p = true; return conv; } @@ -6062,6 +6064,14 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, expr = CONSTRUCTOR_ELT (expr, 0)->value; } + /* Give a helpful error if this is bad because a conversion to bool + from std::nullptr_t requires direct-initialization. */ + if (NULLPTR_TYPE_P (TREE_TYPE (expr)) + && TREE_CODE (totype) == BOOLEAN_TYPE) + complained = permerror (loc, "converting to %qT from %qT requires " + "direct-initialization", + totype, TREE_TYPE (expr)); + for (; t ; t = next_conversion (t)) { if (t->kind == ck_user && t->cand->reason) |