* typeck.c (decay_conversion): Don't discard side-effects from
expressions of nullptr_t.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@188954
138bc75d-0d04-0410-961f-
82ee72b054a4
2012-06-25 Jason Merrill <jason@redhat.com>
+ PR c++/52988
+ * typeck.c (decay_conversion): Don't discard side-effects from
+ expressions of nullptr_t.
+
PR c++/53202
* semantics.c (build_data_member_initialization): Always keep
initializer for empty base.
if (error_operand_p (exp))
return error_mark_node;
- if (NULLPTR_TYPE_P (type))
+ if (NULLPTR_TYPE_P (type) && !TREE_SIDE_EFFECTS (exp))
return nullptr_node;
/* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
2012-06-25 Jason Merrill <jason@redhat.com>
+ PR c++/52988
+ * g++.dg/cpp0x/nullptr28.C: New.
+
PR c++/53202
* g++.dg/cpp0x/constexpr-tuple.C: New.
--- /dev/null
+// { dg-do run { target c++11 } }
+
+typedef decltype(nullptr) nullptr_t;
+
+int i;
+nullptr_t n;
+const nullptr_t& f() { ++i; return n; }
+
+nullptr_t g() { return f(); }
+
+int main()
+{
+ g();
+ if (i != 1)
+ __builtin_abort ();
+}