c-common.def (SIZEOF_EXPR, [...]): Remove.
authorIan Lance Taylor <ian@airs.com>
Sun, 17 Apr 2005 21:27:47 +0000 (21:27 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Sun, 17 Apr 2005 21:27:47 +0000 (21:27 +0000)
./ * 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

gcc/ChangeLog
gcc/c-common.c
gcc/c-common.def
gcc/c-common.h
gcc/c-pretty-print.c
gcc/cp/ChangeLog
gcc/cp/cp-tree.def
gcc/cp/cxx-pretty-print.c
gcc/cp/typeck.c

index 053beb9bbfc6cdd5ef21cb615c77c6682632082a..64c39f9ece06cce988d9cc4daf2d22ca02e86006 100644 (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.
index da6be4e21a6a94e17a4a05201a05d57dea0c7af2..7f1ac51eba01d930dce636638dd972368e9af62b 100644 (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)
index 381fe4ef75c423105f8fcd739806c778a3b406b7..b352364e95aae173d34dfcc7174e6c05ecdd626c 100644 (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)
index cf6e88b9fa65318424bcd79e4252a2c560d3d518..9d98ffb65d1cf3c54ae268a938acc3697694130d 100644 (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
index 21af965b13818a95fe1711915f1290b144c89f69..24220ce6241057704253f39e9ec7dba13d1ffb46 100644 (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);
index 81e75b9148d41da4e17388ae22b1ee8c6493a035..e26a97936711fd813d7784246587a3080987c2d9 100644 (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
index 674de59f7b5075a0a2841fcb3d1e025975efdc95..ffcc9a51622e6be469245e0de5c58c079a700b23 100644 (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
index e185defa88e26794fd9055ac71bd92b0eedbafa6..854efeccd361c757500268ad4ccf0e92a53399c8 100644 (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;
index 6ccffe1ceeb6c093068cb8710a35eeb6d8055b73..28295767df6639cad07e6bce7b3eb9b10f428fbc 100644 (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;
 }