From 75d980abcc4dbd2bcb3d06c3f12ef9312ccac856 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 24 Sep 2010 11:13:08 -0400 Subject: error.c (dump_expr): Print conversion between reference and pointer to the same type as "*" or "&". * error.c (dump_expr) [CASE_CONVERT]: Print conversion between reference and pointer to the same type as "*" or "&". From-SVN: r164597 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/error.c | 17 +++++++++++++++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/other/error10.C | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 95613b0..f457d0c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2010-09-24 Jason Merrill + + * error.c (dump_expr) [CASE_CONVERT]: Print conversion between + reference and pointer to the same type as "*" or "&". + 2010-09-24 Nicola Pero * typeck.c (warn_args_num): Use warning 'too many arguments to diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 981b71f..be3dd2c 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1949,8 +1949,21 @@ dump_expr (tree t, int flags) case VIEW_CONVERT_EXPR: { tree op = TREE_OPERAND (t, 0); - - if (!same_type_p (TREE_TYPE (op), TREE_TYPE (t))) + tree ttype = TREE_TYPE (t); + tree optype = TREE_TYPE (op); + + if (TREE_CODE (ttype) != TREE_CODE (optype) + && POINTER_TYPE_P (ttype) + && POINTER_TYPE_P (optype) + && same_type_p (TREE_TYPE (optype), + TREE_TYPE (ttype))) + { + if (TREE_CODE (ttype) == REFERENCE_TYPE) + dump_unary_op ("*", t, flags); + else + dump_unary_op ("&", t, flags); + } + else if (!same_type_p (TREE_TYPE (op), TREE_TYPE (t))) { /* It is a cast, but we cannot tell whether it is a reinterpret or static cast. Use the C style notation. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1917147..659dab2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-09-24 Jason Merrill + + * g++.dg/other/error10.C: Adjust expected output. + 2010-09-24 Jakub Jelinek PR middle-end/45234 diff --git a/gcc/testsuite/g++.dg/other/error10.C b/gcc/testsuite/g++.dg/other/error10.C index 9e6da65..26f7ca5 100644 --- a/gcc/testsuite/g++.dg/other/error10.C +++ b/gcc/testsuite/g++.dg/other/error10.C @@ -6,7 +6,7 @@ template struct A {}; template void foo(const A &a) -{ -A(a); } // { dg-error "\\(\\(const A<0>\\*\\)a\\)" "" } +{ -A(a); } // { dg-error "\\(\\* & a\\)" "" } void bar() { -- cgit v1.1