From f3146d75a925306d35d582c3c927d06ce93aa03d Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 21 Mar 2003 15:42:36 +0000 Subject: [PATCH] re PR c++/9898 (Template reference cast operator of template class) cp: PR c++/9898 * error.c (dump_decl) [CONST_DECL]: Print ''. (dump_expr) [CONSTRUCTOR]: Print default ctor as a function call. testsuite: PR c++/9898 * g++.dg/other/error4.C: New test. From-SVN: r64667 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/error.c | 18 ++++++++++++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/other/error4.C | 15 +++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/error4.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9b0eaf1b39c..2546ea12fd0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-03-21 Nathan Sidwell + + PR c++/9898 + * error.c (dump_decl) [CONST_DECL]: Print ''. + (dump_expr) [CONSTRUCTOR]: Print default ctor as a function call. + 2003-03-20 Mark Mitchell * cp/decl2.c (arg_assoc_class): Correct check for namespace-scope diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 42a7ff774e9..e687ac014b8 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -971,7 +971,7 @@ dump_decl (tree t, int flags) else if (DECL_INITIAL (t)) dump_expr (DECL_INITIAL (t), flags | TFF_EXPR_IN_PARENS); else - print_identifier (scratch_buffer, "enumerator"); + print_identifier (scratch_buffer, ""); break; case USING_DECL: @@ -1844,9 +1844,19 @@ dump_expr (tree t, int flags) } } } - output_add_character (scratch_buffer, '{'); - dump_expr_list (CONSTRUCTOR_ELTS (t), flags); - output_add_character (scratch_buffer, '}'); + if (TREE_TYPE (t) && !CONSTRUCTOR_ELTS (t)) + { + dump_type (TREE_TYPE (t), 0); + output_add_character (scratch_buffer, '('); + output_add_character (scratch_buffer, ')'); + } + else + { + output_add_character (scratch_buffer, '{'); + dump_expr_list (CONSTRUCTOR_ELTS (t), flags); + output_add_character (scratch_buffer, '}'); + } + break; case OFFSET_REF: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a76454bb1c3..9bda0cd590d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-03-21 Nathan Sidwell + + PR c++/9898 + * g++.dg/other/error4.C: New test. + 2003-03-20 Mark Mitchell * g++.dg/template/friend17.C: New test. diff --git a/gcc/testsuite/g++.dg/other/error4.C b/gcc/testsuite/g++.dg/other/error4.C new file mode 100644 index 00000000000..39a612b34f0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error4.C @@ -0,0 +1,15 @@ +// { dg-do compile } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 21 Mar 2003 + +// PR 9898. Confusing error message + +struct Wrapper {}; + +void Foo(int const &); // { dg-error "in passing" "" } + +void Baz () +{ + Foo (Wrapper ()); // { dg-error "convert `Wrapper *\\(\\)' to" "" } +}