diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/cp-tree.def | 10 | ||||
-rw-r--r-- | gcc/cp/cxx-pretty-print.c | 25 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 4 |
4 files changed, 49 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 81e75b9148d..e26a9793671 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2005-04-17 Ian Lance Taylor <ian@airs.com> + + * cp-tree.def: Add SIZEOF_EXPR, ARROW_EXPR and ALIGNOF_EXPR. + * cxx-pretty-print.c (pp_cxx_postfix_expression): Handle + ARROW_EXPR. + (pp_cxx_unary_expression): Handle SIZEOF_EXPR and ALIGNOF_EXPR. + (pp_cxx_expression): Handle ARROW_EXPR, SIZEOF_EXPR, and + ALIGNOF_EXPR. + * typeck.c (cxx_sizeof_or_alignof_type): Update call to + c_sizeof_or_alignof_type for change in parameter type. + 2005-04-16 Mark Mitchell <mark@codesourcery.com> PR c++/21025 diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 674de59f7b5..ffcc9a51622 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -321,6 +321,16 @@ DEFTREECODE (TINST_LEVEL, "TINST_LEVEL", tcc_exceptional, 0) /* Represents an 'offsetof' expression during template expansion. */ DEFTREECODE (OFFSETOF_EXPR, "offsetof_expr", tcc_expression, 1) +/* Represents a 'sizeof' expression during template expansion. */ +DEFTREECODE (SIZEOF_EXPR, "sizeof_expr", tcc_unary, 1) + +/* Represents the -> operator during template expansion. */ +DEFTREECODE (ARROW_EXPR, "arrow_expr", tcc_expression, 1) + +/* Represents an '__alignof__' expression during template + expansion. */ +DEFTREECODE (ALIGNOF_EXPR, "alignof_expr", tcc_unary, 1) + /* Local variables: mode:c diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index e185defa88e..854efeccd36 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -490,6 +490,11 @@ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t) pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 2)); break; + case ARROW_EXPR: + pp_cxx_postfix_expression (pp, TREE_OPERAND (t, 0)); + pp_cxx_arrow (pp); + break; + default: pp_c_postfix_expression (pp_c_base (pp), t); break; @@ -615,6 +620,20 @@ pp_cxx_unary_expression (cxx_pretty_printer *pp, tree t) pp_cxx_delete_expression (pp, t); break; + case SIZEOF_EXPR: + case ALIGNOF_EXPR: + pp_cxx_identifier (pp, code == SIZEOF_EXPR ? "sizeof" : "__alignof__"); + pp_cxx_whitespace (pp); + if (TYPE_P (TREE_OPERAND (t, 0))) + { + pp_cxx_left_paren (pp); + pp_cxx_type_id (pp, TREE_OPERAND (t, 0)); + pp_cxx_right_paren (pp); + } + else + pp_unary_expression (pp, TREE_OPERAND (t, 0)); + break; + default: pp_c_unary_expression (pp_c_base (pp), t); break; @@ -859,6 +878,7 @@ pp_cxx_expression (cxx_pretty_printer *pp, tree t) case TYPEID_EXPR: case PSEUDO_DTOR_EXPR: case AGGR_INIT_EXPR: + case ARROW_EXPR: pp_cxx_postfix_expression (pp, t); break; @@ -872,6 +892,11 @@ pp_cxx_expression (cxx_pretty_printer *pp, tree t) pp_cxx_delete_expression (pp, t); break; + case SIZEOF_EXPR: + case ALIGNOF_EXPR: + pp_cxx_unary_expression (pp, t); + break; + case CAST_EXPR: pp_cxx_cast_expression (pp, t); break; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 6ccffe1ceeb..28295767df6 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1240,7 +1240,9 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain) value = size_one_node; } else - value = c_sizeof_or_alignof_type (complete_type (type), op, complain); + value = c_sizeof_or_alignof_type (complete_type (type), + op == SIZEOF_EXPR, + complain); return value; } |