c-common.def (SIZEOF_EXPR, [...]): Remove.

./	* 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.

From-SVN: r98297
This commit is contained in:
Ian Lance Taylor 2005-04-17 21:27:47 +00:00 committed by Ian Lance Taylor
parent 81a60083ea
commit 03a0866432
9 changed files with 71 additions and 31 deletions

View file

@ -1,3 +1,17 @@
2005-04-17 Ian Lance Taylor <ian@airs.com>
* 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 <ian@airs.com>
* system.h: Poison DONT_ACCESS_GBLS_AFTER_EPILOGUE.

View file

@ -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 %<sizeof%> 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)

View file

@ -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)

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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;
}