re PR c++/51379 ([C++0x] [DR 799] reinterpret_cast is not particularly useful)

/cp
2012-01-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51379
	* typeck.c (build_reinterpret_cast_1): Implement resolution of
	DR 799.

/testsuite
2012-01-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51379
	* g++.dg/conversion/reinterpret4.C: New.
	* g++.dg/conversion/reinterpret1.C: Adjust.

From-SVN: r182775
This commit is contained in:
Paolo Carlini 2012-01-01 20:21:36 +00:00
parent b81e8df838
commit 9f88ff5a1f
5 changed files with 23 additions and 2 deletions

View File

@ -1,4 +1,10 @@
2011-12-31 Fabien Chêne <fabien@gcc.gnu.org>
2012-01-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51379
* typeck.c (build_reinterpret_cast_1): Implement resolution of
DR 799.
2012-01-01 Fabien Chêne <fabien@gcc.gnu.org>
* parser.c (cp_parser_using_declaration): Add a warning about
deprecated access declarations when no errors were encountered

View File

@ -6203,6 +6203,11 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p,
else if (TYPE_PTR_P (type) && INTEGRAL_OR_ENUMERATION_TYPE_P (intype))
/* OK */
;
else if ((INTEGRAL_OR_ENUMERATION_TYPE_P (type)
|| TYPE_PTR_P (type) || TYPE_PTR_TO_MEMBER_P (type))
&& same_type_p (type, intype))
/* DR 799 */
return fold_if_not_in_template (build_nop (type, expr));
else if ((TYPE_PTRFN_P (type) && TYPE_PTRFN_P (intype))
|| (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype)))
return fold_if_not_in_template (build_nop (type, expr));

View File

@ -1,3 +1,9 @@
2012-01-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51379
* g++.dg/conversion/reinterpret4.C: New.
* g++.dg/conversion/reinterpret1.C: Adjust.
2012-01-01 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/constexpr-delegating2.C: Add missing piece.

View File

@ -3,4 +3,4 @@
struct Y { Y(int &); };
int v;
Y y1(reinterpret_cast<int>(v)); // { dg-error "" }
Y y1(reinterpret_cast<int>(v));

View File

@ -0,0 +1,4 @@
// PR c++/51379
unsigned long t1 = 1;
unsigned long t2 = reinterpret_cast<unsigned long>(t1);