Commit dcbb27dd by Jason Merrill Committed by Jason Merrill

PR c++/68810 - wrong location for reinterpret_cast error.

	* cvt.c (cp_convert_to_pointer): Always build a CONVERT_EXPR when
	!dofold.

From-SVN: r257161
parent b07c3651
2018-01-29 Jason Merrill <jason@redhat.com>
PR c++/68810 - wrong location for reinterpret_cast error.
* cvt.c (cp_convert_to_pointer): Always build a CONVERT_EXPR when
!dofold.
2018-01-29 Marek Polacek <polacek@redhat.com> 2018-01-29 Marek Polacek <polacek@redhat.com>
PR c++/83996 PR c++/83996
......
...@@ -239,6 +239,11 @@ cp_convert_to_pointer (tree type, tree expr, bool dofold, ...@@ -239,6 +239,11 @@ cp_convert_to_pointer (tree type, tree expr, bool dofold,
gcc_assert (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (expr))) gcc_assert (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (expr)))
== GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type))); == GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)));
/* FIXME needed because convert_to_pointer_maybe_fold still folds
conversion of constants. */
if (!dofold)
return build1 (CONVERT_EXPR, type, expr);
return convert_to_pointer_maybe_fold (type, expr, dofold); return convert_to_pointer_maybe_fold (type, expr, dofold);
} }
......
...@@ -16,7 +16,9 @@ public: ...@@ -16,7 +16,9 @@ public:
constexpr static Inner & getInner() constexpr static Inner & getInner()
/* I am surprised this is considered a constexpr */ /* I am surprised this is considered a constexpr */
{ return *((Inner *)4); } // { dg-error "reinterpret_cast" } {
return *((Inner *)4); // { dg-error "reinterpret_cast" }
}
}; };
B B::instance; B B::instance;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment