From 2d65b828b292adf5e39bb71addbd671217211cd5 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 18 Sep 2007 15:38:02 +0000 Subject: re PR c++/33463 (Broken diagnostic: 'typeid_expr' not supported by dump_expr) /cp 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. /testsuite 2007-09-18 Paolo Carlini PR c++/33463 * g++.dg/rtti/typeid6.C: New. From-SVN: r128582 --- gcc/cp/ChangeLog | 10 ++++++++++ gcc/cp/cxx-pretty-print.c | 22 ++++++++++++++-------- gcc/cp/cxx-pretty-print.h | 1 + gcc/cp/error.c | 4 ++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/rtti/typeid6.C | 11 +++++++++++ 6 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/rtti/typeid6.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c0610b0..504a0c3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,15 @@ 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-09-18 Paolo Carlini + PR c++/33464 * cxx-pretty-print.c (pp_cxx_trait_expression): Add. (pp_cxx_primary_expression): Use it. diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 156f579..a73a052 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -571,14 +571,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: @@ -2147,6 +2140,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); +} + +void pp_cxx_trait_expression (cxx_pretty_printer *pp, tree t) { cp_trait_kind kind = TRAIT_EXPR_KIND (t); diff --git a/gcc/cp/cxx-pretty-print.h b/gcc/cp/cxx-pretty-print.h index 2ae834f..f399fea 100644 --- a/gcc/cp/cxx-pretty-print.h +++ b/gcc/cp/cxx-pretty-print.h @@ -70,5 +70,6 @@ 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_trait_expression (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 b68df74..1854fd6 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2058,6 +2058,10 @@ dump_expr (tree t, int flags) pp_cxx_trait_expression (cxx_pp, t); 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 882780f..fe88025 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2007-09-18 Paolo Carlini + PR c++/33463 + * g++.dg/rtti/typeid6.C: New. + +2007-09-18 Paolo Carlini + PR c++/33464 * g++.dg/ext/is_class_error.C: Rename to is_class_error1.C. * g++.dg/ext/is_class_error2.C: New. diff --git a/gcc/testsuite/g++.dg/rtti/typeid6.C b/gcc/testsuite/g++.dg/rtti/typeid6.C new file mode 100644 index 0000000..18709b4 --- /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" } +} -- cgit v1.1