Commit 03a08664 by Ian Lance Taylor Committed by Ian Lance Taylor

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
parent 81a60083
2005-04-17 Ian Lance Taylor <ian@airs.com> 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. * system.h: Poison DONT_ACCESS_GBLS_AFTER_EPILOGUE.
2005-04-17 Richard Henderson <rth@redhat.com> 2005-04-17 Richard Henderson <rth@redhat.com>
......
...@@ -2786,19 +2786,19 @@ c_common_get_alias_set (tree t) ...@@ -2786,19 +2786,19 @@ c_common_get_alias_set (tree t)
second parameter indicates which OPERATOR is being applied. The COMPLAIN second parameter indicates which OPERATOR is being applied. The COMPLAIN
flag controls whether we should diagnose possibly ill-formed flag controls whether we should diagnose possibly ill-formed
constructs or not. */ constructs or not. */
tree 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; const char *op_name;
tree value = NULL; tree value = NULL;
enum tree_code type_code = TREE_CODE (type); enum tree_code type_code = TREE_CODE (type);
gcc_assert (op == SIZEOF_EXPR || op == ALIGNOF_EXPR); op_name = is_sizeof ? "sizeof" : "__alignof__";
op_name = op == SIZEOF_EXPR ? "sizeof" : "__alignof__";
if (type_code == FUNCTION_TYPE) if (type_code == FUNCTION_TYPE)
{ {
if (op == SIZEOF_EXPR) if (is_sizeof)
{ {
if (complain && (pedantic || warn_pointer_arith)) if (complain && (pedantic || warn_pointer_arith))
pedwarn ("invalid application of %<sizeof%> to a function type"); 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) ...@@ -2823,7 +2823,7 @@ c_sizeof_or_alignof_type (tree type, enum tree_code op, int complain)
} }
else else
{ {
if (op == (enum tree_code) SIZEOF_EXPR) if (is_sizeof)
/* Convert in case a char is more than one unit. */ /* Convert in case a char is more than one unit. */
value = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type), value = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
size_int (TYPE_PRECISION (char_type_node) size_int (TYPE_PRECISION (char_type_node)
......
...@@ -25,10 +25,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -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 /* Tree nodes relevant to both C and C++. These were originally in
cp-tree.def in the cp subdir. */ 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 /* Used to represent an expression statement. Use `EXPR_STMT_EXPR' to
obtain the expression. */ obtain the expression. */
DEFTREECODE (EXPR_STMT, "expr_stmt", tcc_expression, 1) DEFTREECODE (EXPR_STMT, "expr_stmt", tcc_expression, 1)
......
...@@ -636,7 +636,7 @@ extern tree c_common_signed_type (tree); ...@@ -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_signed_or_unsigned_type (int, tree);
extern tree c_common_truthvalue_conversion (tree); extern tree c_common_truthvalue_conversion (tree);
extern void c_apply_type_quals_to_decl (int, 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); extern tree c_alignof_expr (tree);
/* Print an error message for invalid operands to arith operation CODE. /* Print an error message for invalid operands to arith operation CODE.
NOP_EXPR is used as a special case (see truthvalue_conversion). */ NOP_EXPR is used as a special case (see truthvalue_conversion). */
...@@ -649,8 +649,8 @@ extern void overflow_warning (tree); ...@@ -649,8 +649,8 @@ extern void overflow_warning (tree);
extern void unsigned_conversion_warning (tree, tree); extern void unsigned_conversion_warning (tree, tree);
extern bool c_determine_visibility (tree); extern bool c_determine_visibility (tree);
#define c_sizeof(T) c_sizeof_or_alignof_type (T, SIZEOF_EXPR, 1) #define c_sizeof(T) c_sizeof_or_alignof_type (T, true, 1)
#define c_alignof(T) c_sizeof_or_alignof_type (T, ALIGNOF_EXPR, 1) #define c_alignof(T) c_sizeof_or_alignof_type (T, false, 1)
/* Subroutine of build_binary_op, used for comparison operations. /* Subroutine of build_binary_op, used for comparison operations.
See if the operands have both been converted from subword integer types See if the operands have both been converted from subword integer types
......
...@@ -1223,11 +1223,6 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e) ...@@ -1223,11 +1223,6 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e)
pp_identifier (pp, code == POSTINCREMENT_EXPR ? "++" : "--"); pp_identifier (pp, code == POSTINCREMENT_EXPR ? "++" : "--");
break; break;
case ARROW_EXPR:
pp_postfix_expression (pp, TREE_OPERAND (e, 0));
pp_c_arrow (pp);
break;
case ARRAY_REF: case ARRAY_REF:
pp_postfix_expression (pp, TREE_OPERAND (e, 0)); pp_postfix_expression (pp, TREE_OPERAND (e, 0));
pp_c_left_bracket (pp); pp_c_left_bracket (pp);
...@@ -1430,16 +1425,6 @@ pp_c_unary_expression (c_pretty_printer *pp, tree e) ...@@ -1430,16 +1425,6 @@ pp_c_unary_expression (c_pretty_printer *pp, tree e)
pp_c_cast_expression (pp, TREE_OPERAND (e, 0)); pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
break; 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 REALPART_EXPR:
case IMAGPART_EXPR: case IMAGPART_EXPR:
pp_c_identifier (pp, code == REALPART_EXPR ? "__real__" : "__imag__"); pp_c_identifier (pp, code == REALPART_EXPR ? "__real__" : "__imag__");
...@@ -1807,7 +1792,6 @@ pp_c_expression (c_pretty_printer *pp, tree e) ...@@ -1807,7 +1792,6 @@ pp_c_expression (c_pretty_printer *pp, tree e)
case POSTINCREMENT_EXPR: case POSTINCREMENT_EXPR:
case POSTDECREMENT_EXPR: case POSTDECREMENT_EXPR:
case ARROW_EXPR:
case ARRAY_REF: case ARRAY_REF:
case CALL_EXPR: case CALL_EXPR:
case COMPONENT_REF: case COMPONENT_REF:
...@@ -1837,8 +1821,6 @@ pp_c_expression (c_pretty_printer *pp, tree e) ...@@ -1837,8 +1821,6 @@ pp_c_expression (c_pretty_printer *pp, tree e)
case TRUTH_NOT_EXPR: case TRUTH_NOT_EXPR:
case PREINCREMENT_EXPR: case PREINCREMENT_EXPR:
case PREDECREMENT_EXPR: case PREDECREMENT_EXPR:
case SIZEOF_EXPR:
case ALIGNOF_EXPR:
case REALPART_EXPR: case REALPART_EXPR:
case IMAGPART_EXPR: case IMAGPART_EXPR:
pp_c_unary_expression (pp, e); pp_c_unary_expression (pp, e);
......
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> 2005-04-16 Mark Mitchell <mark@codesourcery.com>
PR c++/21025 PR c++/21025
......
...@@ -321,6 +321,16 @@ DEFTREECODE (TINST_LEVEL, "TINST_LEVEL", tcc_exceptional, 0) ...@@ -321,6 +321,16 @@ DEFTREECODE (TINST_LEVEL, "TINST_LEVEL", tcc_exceptional, 0)
/* Represents an 'offsetof' expression during template expansion. */ /* Represents an 'offsetof' expression during template expansion. */
DEFTREECODE (OFFSETOF_EXPR, "offsetof_expr", tcc_expression, 1) 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: Local variables:
mode:c mode:c
......
...@@ -490,6 +490,11 @@ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t) ...@@ -490,6 +490,11 @@ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t)
pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 2)); pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 2));
break; break;
case ARROW_EXPR:
pp_cxx_postfix_expression (pp, TREE_OPERAND (t, 0));
pp_cxx_arrow (pp);
break;
default: default:
pp_c_postfix_expression (pp_c_base (pp), t); pp_c_postfix_expression (pp_c_base (pp), t);
break; break;
...@@ -615,6 +620,20 @@ pp_cxx_unary_expression (cxx_pretty_printer *pp, tree t) ...@@ -615,6 +620,20 @@ pp_cxx_unary_expression (cxx_pretty_printer *pp, tree t)
pp_cxx_delete_expression (pp, t); pp_cxx_delete_expression (pp, t);
break; 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: default:
pp_c_unary_expression (pp_c_base (pp), t); pp_c_unary_expression (pp_c_base (pp), t);
break; break;
...@@ -859,6 +878,7 @@ pp_cxx_expression (cxx_pretty_printer *pp, tree t) ...@@ -859,6 +878,7 @@ pp_cxx_expression (cxx_pretty_printer *pp, tree t)
case TYPEID_EXPR: case TYPEID_EXPR:
case PSEUDO_DTOR_EXPR: case PSEUDO_DTOR_EXPR:
case AGGR_INIT_EXPR: case AGGR_INIT_EXPR:
case ARROW_EXPR:
pp_cxx_postfix_expression (pp, t); pp_cxx_postfix_expression (pp, t);
break; break;
...@@ -872,6 +892,11 @@ pp_cxx_expression (cxx_pretty_printer *pp, tree t) ...@@ -872,6 +892,11 @@ pp_cxx_expression (cxx_pretty_printer *pp, tree t)
pp_cxx_delete_expression (pp, t); pp_cxx_delete_expression (pp, t);
break; break;
case SIZEOF_EXPR:
case ALIGNOF_EXPR:
pp_cxx_unary_expression (pp, t);
break;
case CAST_EXPR: case CAST_EXPR:
pp_cxx_cast_expression (pp, t); pp_cxx_cast_expression (pp, t);
break; break;
......
...@@ -1240,7 +1240,9 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain) ...@@ -1240,7 +1240,9 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain)
value = size_one_node; value = size_one_node;
} }
else 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; return value;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment