From: ian Date: Sun, 17 Apr 2005 21:27:47 +0000 (+0000) Subject: ./ X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=908c697e9e419d3f9d870eafcf400a7b9f927695 ./ * c-common.def (SIZEOF_EXPR, ARROW_EXPR, ALIGNOF_EXPR): Remove. * c-common.c (c_sizeof_or_alignof_type): Change second parameter from enum tree_code op to bool is_sizeof. * c-common.h (c_sizeof_or_alignof_type): Update declaration. (c_sizeof, c_alignof): Update calls to c_sizeof_or_alignof_type. * c-pretty-print.c (pp_c_postfix_expression): Remove ARROW_EXPR case. (pp_c_unary_expression): Remove SIZEOF_EXPR and ALIGNOF_EXPR cases. (pp_c_expression): Remove ARROW_EXPR, SIZEOF_EXPR, and ALIGNOF_EXPR cases. cp/ * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98297 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 053beb9bbfc..64c39f9ece0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,19 @@ 2005-04-17 Ian Lance Taylor + * c-common.def (SIZEOF_EXPR, ARROW_EXPR, ALIGNOF_EXPR): Remove. + * c-common.c (c_sizeof_or_alignof_type): Change second parameter + from enum tree_code op to bool is_sizeof. + * c-common.h (c_sizeof_or_alignof_type): Update declaration. + (c_sizeof, c_alignof): Update calls to c_sizeof_or_alignof_type. + * c-pretty-print.c (pp_c_postfix_expression): Remove ARROW_EXPR + case. + (pp_c_unary_expression): Remove SIZEOF_EXPR and ALIGNOF_EXPR + cases. + (pp_c_expression): Remove ARROW_EXPR, SIZEOF_EXPR, and + ALIGNOF_EXPR cases. + +2005-04-17 Ian Lance Taylor + * system.h: Poison DONT_ACCESS_GBLS_AFTER_EPILOGUE. 2005-04-17 Richard Henderson diff --git a/gcc/c-common.c b/gcc/c-common.c index da6be4e21a6..7f1ac51eba0 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2786,19 +2786,19 @@ c_common_get_alias_set (tree t) second parameter indicates which OPERATOR is being applied. The COMPLAIN flag controls whether we should diagnose possibly ill-formed constructs or not. */ + tree -c_sizeof_or_alignof_type (tree type, enum tree_code op, int complain) +c_sizeof_or_alignof_type (tree type, bool is_sizeof, int complain) { const char *op_name; tree value = NULL; enum tree_code type_code = TREE_CODE (type); - gcc_assert (op == SIZEOF_EXPR || op == ALIGNOF_EXPR); - op_name = op == SIZEOF_EXPR ? "sizeof" : "__alignof__"; + op_name = is_sizeof ? "sizeof" : "__alignof__"; if (type_code == FUNCTION_TYPE) { - if (op == SIZEOF_EXPR) + if (is_sizeof) { if (complain && (pedantic || warn_pointer_arith)) pedwarn ("invalid application of % to a function type"); @@ -2823,7 +2823,7 @@ c_sizeof_or_alignof_type (tree type, enum tree_code op, int complain) } else { - if (op == (enum tree_code) SIZEOF_EXPR) + if (is_sizeof) /* Convert in case a char is more than one unit. */ value = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type), size_int (TYPE_PRECISION (char_type_node) diff --git a/gcc/c-common.def b/gcc/c-common.def index 381fe4ef75c..b352364e95a 100644 --- a/gcc/c-common.def +++ b/gcc/c-common.def @@ -25,10 +25,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA /* Tree nodes relevant to both C and C++. These were originally in cp-tree.def in the cp subdir. */ -DEFTREECODE (SIZEOF_EXPR, "sizeof_expr", tcc_unary, 1) -DEFTREECODE (ARROW_EXPR, "arrow_expr", tcc_expression, 1) -DEFTREECODE (ALIGNOF_EXPR, "alignof_expr", tcc_unary, 1) - /* Used to represent an expression statement. Use `EXPR_STMT_EXPR' to obtain the expression. */ DEFTREECODE (EXPR_STMT, "expr_stmt", tcc_expression, 1) diff --git a/gcc/c-common.h b/gcc/c-common.h index cf6e88b9fa6..9d98ffb65d1 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -636,7 +636,7 @@ extern tree c_common_signed_type (tree); extern tree c_common_signed_or_unsigned_type (int, tree); extern tree c_common_truthvalue_conversion (tree); extern void c_apply_type_quals_to_decl (int, tree); -extern tree c_sizeof_or_alignof_type (tree, enum tree_code, int); +extern tree c_sizeof_or_alignof_type (tree, bool, int); extern tree c_alignof_expr (tree); /* Print an error message for invalid operands to arith operation CODE. NOP_EXPR is used as a special case (see truthvalue_conversion). */ @@ -649,8 +649,8 @@ extern void overflow_warning (tree); extern void unsigned_conversion_warning (tree, tree); extern bool c_determine_visibility (tree); -#define c_sizeof(T) c_sizeof_or_alignof_type (T, SIZEOF_EXPR, 1) -#define c_alignof(T) c_sizeof_or_alignof_type (T, ALIGNOF_EXPR, 1) +#define c_sizeof(T) c_sizeof_or_alignof_type (T, true, 1) +#define c_alignof(T) c_sizeof_or_alignof_type (T, false, 1) /* Subroutine of build_binary_op, used for comparison operations. See if the operands have both been converted from subword integer types diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c index 21af965b138..24220ce6241 100644 --- a/gcc/c-pretty-print.c +++ b/gcc/c-pretty-print.c @@ -1223,11 +1223,6 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e) pp_identifier (pp, code == POSTINCREMENT_EXPR ? "++" : "--"); break; - case ARROW_EXPR: - pp_postfix_expression (pp, TREE_OPERAND (e, 0)); - pp_c_arrow (pp); - break; - case ARRAY_REF: pp_postfix_expression (pp, TREE_OPERAND (e, 0)); pp_c_left_bracket (pp); @@ -1430,16 +1425,6 @@ pp_c_unary_expression (c_pretty_printer *pp, tree e) pp_c_cast_expression (pp, TREE_OPERAND (e, 0)); break; - case SIZEOF_EXPR: - case ALIGNOF_EXPR: - pp_c_identifier (pp, code == SIZEOF_EXPR ? "sizeof" : "__alignof__"); - pp_c_whitespace (pp); - if (TYPE_P (TREE_OPERAND (e, 0))) - pp_c_type_cast (pp, TREE_OPERAND (e, 0)); - else - pp_unary_expression (pp, TREE_OPERAND (e, 0)); - break; - case REALPART_EXPR: case IMAGPART_EXPR: pp_c_identifier (pp, code == REALPART_EXPR ? "__real__" : "__imag__"); @@ -1807,7 +1792,6 @@ pp_c_expression (c_pretty_printer *pp, tree e) case POSTINCREMENT_EXPR: case POSTDECREMENT_EXPR: - case ARROW_EXPR: case ARRAY_REF: case CALL_EXPR: case COMPONENT_REF: @@ -1837,8 +1821,6 @@ pp_c_expression (c_pretty_printer *pp, tree e) case TRUTH_NOT_EXPR: case PREINCREMENT_EXPR: case PREDECREMENT_EXPR: - case SIZEOF_EXPR: - case ALIGNOF_EXPR: case REALPART_EXPR: case IMAGPART_EXPR: pp_c_unary_expression (pp, e); 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 + + * 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 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; }