From patchwork Fri Aug 6 19:34:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: C++ PATCH for nullptr decay Date: Fri, 06 Aug 2010 09:34:17 -0000 From: Jason Merrill X-Patchwork-Id: 61134 Message-Id: <4C5C63B9.6040004@redhat.com> To: gcc-patches List On the constexpr branch, some testcases were confused by nullptr_t variables not clearly having a constant value. I've fixed this by causing them to decay to nullptr. Tested x86_64-pc-linux-gnu, applied to trunk. commit 171913d18ec1a2ccefc1921cf259cdef1ca37dac Author: Jason Merrill Date: Fri Aug 6 20:10:29 2010 +0200 * typeck.c (decay_conversion): Any expression with type nullptr_t decays to nullptr. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 484d299..177f4bb 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1920,6 +1920,9 @@ decay_conversion (tree exp) if (error_operand_p (exp)) return error_mark_node; + if (NULLPTR_TYPE_P (type)) + return nullptr_node; + /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. Leave such NOP_EXPRs, since RHS is being used in non-lvalue context. */ code = TREE_CODE (type);