diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-10-27 13:58:26 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2007-10-27 13:58:26 +0200 |
commit | 094a5fe2659e4bf82420bfe1cdb57cc799a37644 (patch) | |
tree | 5162a0eff158259f8a026fc2fd2b03ff65148d86 /gcc/cp/cxx-pretty-print.c | |
parent | d449b45833001db693cf55eb5326c8eb684bc73e (diff) | |
download | gcc-094a5fe2659e4bf82420bfe1cdb57cc799a37644.zip gcc-094a5fe2659e4bf82420bfe1cdb57cc799a37644.tar.gz gcc-094a5fe2659e4bf82420bfe1cdb57cc799a37644.tar.bz2 |
re PR c++/33842 (Broken diagnostic: 'offsetof_expr' not supported by dump_expr)
PR c++/33842
* cxx-pretty-print.h (pp_cxx_offsetof_expression): New prototype.
* cxx-pretty-print.c (pp_cxx_primary_expression): Handle
OFFSETOF_EXPR.
(pp_cxx_offsetof_expression_1, pp_cxx_offsetof_expression): New
functions.
* error.c (dump_expr): Handle OFFSETOF_EXPR.
* g++.dg/template/error34.C: New test.
From-SVN: r129677
Diffstat (limited to 'gcc/cp/cxx-pretty-print.c')
-rw-r--r-- | gcc/cp/cxx-pretty-print.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 7ad46c6..5cbf82c 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -357,6 +357,7 @@ pp_cxx_id_expression (cxx_pretty_printer *pp, tree t) GNU Extensions: __builtin_va_arg ( assignment-expression , type-id ) + __builtin_offsetof ( type-id, offsetof-expression ) __has_nothrow_assign ( type-id ) __has_nothrow_constructor ( type-id ) @@ -421,6 +422,10 @@ pp_cxx_primary_expression (cxx_pretty_printer *pp, tree t) pp_cxx_va_arg_expression (pp, t); break; + case OFFSETOF_EXPR: + pp_cxx_offsetof_expression (pp, t); + break; + default: pp_c_primary_expression (pp_c_base (pp), t); break; @@ -2177,6 +2182,49 @@ pp_cxx_va_arg_expression (cxx_pretty_printer *pp, tree t) pp_cxx_right_paren (pp); } +static bool +pp_cxx_offsetof_expression_1 (cxx_pretty_printer *pp, tree t) +{ + switch (TREE_CODE (t)) + { + case ARROW_EXPR: + if (TREE_CODE (TREE_OPERAND (t, 0)) == STATIC_CAST_EXPR + && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0)))) + { + pp_cxx_type_id (pp, TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0)))); + pp_cxx_separate_with (pp, ','); + return true; + } + return false; + case COMPONENT_REF: + if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0))) + return false; + if (TREE_CODE (TREE_OPERAND (t, 0)) != ARROW_EXPR) + pp_cxx_dot (pp); + pp_cxx_expression (pp, TREE_OPERAND (t, 1)); + return true; + case ARRAY_REF: + if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0))) + return false; + pp_left_bracket (pp); + pp_cxx_expression (pp, TREE_OPERAND (t, 1)); + pp_right_bracket (pp); + return true; + default: + return false; + } +} + +void +pp_cxx_offsetof_expression (cxx_pretty_printer *pp, tree t) +{ + pp_cxx_identifier (pp, "offsetof"); + pp_cxx_left_paren (pp); + if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0))) + pp_cxx_expression (pp, TREE_OPERAND (t, 0)); + pp_cxx_right_paren (pp); +} + void pp_cxx_trait_expression (cxx_pretty_printer *pp, tree t) { |