From: Volker Reichelt Date: Wed, 2 Jan 2008 23:40:41 +0000 (+0000) Subject: Backport: X-Git-Tag: prereleases/gcc-4.2.3-rc1~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f85ff68a08307a4c58d43b74f3b2dc2303338a58;p=thirdparty%2Fgcc.git Backport: 2007-09-18 Paolo Carlini PR c++/33463 * cxx-pretty-print.c (pp_cxx_postfix_expression): Split out case TYPEID_EXPR to... (pp_cxx_typeid_expression): ... here; use pp_cxx_left_paren and pp_cxx_right_paren. * cxx-pretty-print.h (pp_cxx_typeid_expression): Declare. * error.c (dump_expr): Use it. * g++.dg/rtti/typeid6.C: New. From-SVN: r131265 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 08525af70462..b4f6477c03db 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,16 @@ +2008-01-02 Volker Reichelt + + Backport: + 2007-09-18 Paolo Carlini + + PR c++/33463 + * cxx-pretty-print.c (pp_cxx_postfix_expression): Split + out case TYPEID_EXPR to... + (pp_cxx_typeid_expression): ... here; use pp_cxx_left_paren + and pp_cxx_right_paren. + * cxx-pretty-print.h (pp_cxx_typeid_expression): Declare. + * error.c (dump_expr): Use it. + 2007-12-10 Simon Martin PR c++/34059 diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 01200e53e8ea..104701095028 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -512,14 +512,7 @@ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t) break; case TYPEID_EXPR: - t = TREE_OPERAND (t, 0); - pp_cxx_identifier (pp, "typeid"); - pp_left_paren (pp); - if (TYPE_P (t)) - pp_cxx_type_id (pp, t); - else - pp_cxx_expression (pp, t); - pp_right_paren (pp); + pp_cxx_typeid_expression (pp, t); break; case PSEUDO_DTOR_EXPR: @@ -1968,6 +1961,19 @@ pp_cxx_declaration (cxx_pretty_printer *pp, tree t) } } +void +pp_cxx_typeid_expression (cxx_pretty_printer *pp, tree t) +{ + t = TREE_OPERAND (t, 0); + pp_cxx_identifier (pp, "typeid"); + pp_cxx_left_paren (pp); + if (TYPE_P (t)) + pp_cxx_type_id (pp, t); + else + pp_cxx_expression (pp, t); + pp_cxx_right_paren (pp); +} + typedef c_pretty_print_fn pp_fun; diff --git a/gcc/cp/cxx-pretty-print.h b/gcc/cp/cxx-pretty-print.h index 7acf7b50d7ef..5b6272416557 100644 --- a/gcc/cp/cxx-pretty-print.h +++ b/gcc/cp/cxx-pretty-print.h @@ -69,6 +69,7 @@ void pp_cxx_separate_with (cxx_pretty_printer *, int); void pp_cxx_declaration (cxx_pretty_printer *, tree); void pp_cxx_canonical_template_parameter (cxx_pretty_printer *, tree); +void pp_cxx_typeid_expression (cxx_pretty_printer *, tree); #endif /* GCC_CXX_PRETTY_PRINT_H */ diff --git a/gcc/cp/error.c b/gcc/cp/error.c index f371b48d1d66..60cdc1a509b8 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1893,6 +1893,10 @@ dump_expr (tree t, int flags) dump_expr (TREE_OPERAND (t, 0), flags); break; + case TYPEID_EXPR: + pp_cxx_typeid_expression (cxx_pp, t); + break; + /* This list is incomplete, but should suffice for now. It is very important that `sorry' does not call `report_error_function'. That could cause an infinite loop. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a107af2e4b22..c053dc4c327d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2008-01-02 Volker Reichelt + + Backport: + 2007-09-18 Paolo Carlini + + PR c++/33463 + * g++.dg/rtti/typeid6.C: New. + 2007-12-26 John David Anglin PR c++/33640 diff --git a/gcc/testsuite/g++.dg/rtti/typeid6.C b/gcc/testsuite/g++.dg/rtti/typeid6.C new file mode 100644 index 000000000000..18709b4976d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/typeid6.C @@ -0,0 +1,11 @@ +// PR c++/33463 + +namespace std +{ + class type_info {}; +} + +template void foo() +{ + !typeid(void); // { dg-error "!typeid\\(void\\)|candidates" } +}