diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2a9e50ffbae..2c146e34a2d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +1999-10-21 Mark Mitchell + + * cp-tree.def (EMPTY_CLASS_EXPR): New tree node. + * call.c (build_call): Use EMPTY_CLASS_EXPR instead of RTL_EXPR. + * expr.c (cplus_expand_expr): Expand it. + * ir.texi: Document EMPTY_CLASS_EXPR. + 1999-10-20 Mark Mitchell * cp-tree.h (DECL_NAMESPACE_SCOPE_P): Don't treat template diff --git a/gcc/cp/call.c b/gcc/cp/call.c index dd4e44246f8..b83efd531e5 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -395,10 +395,7 @@ build_call (function, result_type, parms) if (is_empty_class (TREE_TYPE (TREE_VALUE (tmp))) && ! TREE_ADDRESSABLE (TREE_TYPE (TREE_VALUE (tmp)))) { - tree t = make_node (RTL_EXPR); - TREE_TYPE (t) = TREE_TYPE (TREE_VALUE (tmp)); - RTL_EXPR_RTL (t) = const0_rtx; - RTL_EXPR_SEQUENCE (t) = NULL_RTX; + tree t = build (EMPTY_CLASS_EXPR, TREE_TYPE (TREE_VALUE (tmp))); TREE_VALUE (tmp) = build (COMPOUND_EXPR, TREE_TYPE (t), TREE_VALUE (tmp), t); } diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 372ad77593d..d8eb62f65a5 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -70,6 +70,10 @@ DEFTREECODE (AGGR_INIT_EXPR, "aggr_init_expr", 'e', 3) else it is NULL_TREE. */ DEFTREECODE (THROW_EXPR, "throw_expr", 'e', 1) +/* An empty class object. The TREE_TYPE gives the class type. We use + these to avoid actually creating instances of the empty classes. */ +DEFTREECODE (EMPTY_CLASS_EXPR, "empty_class_expr", 'e', 0) + /* Template definition. The following fields have the specified uses, although there are other macros in cp-tree.h that should be used for accessing this data. diff --git a/gcc/cp/ir.texi b/gcc/cp/ir.texi index df9c5db2780..22984131c56 100644 --- a/gcc/cp/ir.texi +++ b/gcc/cp/ir.texi @@ -682,9 +682,10 @@ there is no @code{FIELD_DECL} for the ``base-class portion'' of an object. The @code{TYPE_VFIELD} is a compiler-generated field used to point to -virtual function tables. It does not appear on the @code{TYPE_FIELDS} -list. However, back-ends should handle the @code{TYPE_VFIELD} just like -all the entries on the @code{TYPE_FIELDS} list. +virtual function tables. It may or may not appear on the +@code{TYPE_FIELDS} list. However, back-ends should handle the +@code{TYPE_VFIELD} just like all the entries on the @code{TYPE_FIELDS} +list. The function members are available on the @code{TYPE_METHODS} list. Again, subsequent members are found by following the @code{TREE_CHAIN} @@ -1078,6 +1079,7 @@ the function. @tindex DO_STMT @findex DO_BODY @findex DO_COND +@tindex EMPTY_CLASS_EXPR @tindex EXPR_STMT @findex EXPR_STMT_EXPR @tindex FOR_STMT @@ -1286,6 +1288,12 @@ Used to represent a @code{do} loop. The body of the loop is given by @code{DO_COND}. The condition for a @code{do}-statement is always an expression. +@item EMPTY_CLASS_EXPR + +Used to represent a temporary object of a class with no data whose +address is never taken. (All such objects are interchangeable.) The +@code{TREE_TYPE} represents the type of the object. + @item EXPR_STMT Used to represent an expression statement. Use @code{EXPR_STMT_EXPR} to