1994-02-24 02:02:37 +01:00
|
|
|
/* This file contains the definitions and documentation for the
|
|
|
|
additional tree codes used in the GNU C++ compiler (see tree.def
|
|
|
|
for the standard codes).
|
2000-02-26 21:16:12 +01:00
|
|
|
Copyright (C) 1987, 1988, 1990, 1993, 1997, 1998,
|
2001-01-05 12:41:27 +01:00
|
|
|
1999, 2000, 2001 Free Software Foundation, Inc.
|
1994-02-24 02:02:37 +01:00
|
|
|
Hacked by Michael Tiemann (tiemann@cygnus.com)
|
|
|
|
|
|
|
|
This file is part of GNU CC.
|
|
|
|
|
|
|
|
GNU CC is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
GNU CC is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GNU CC; see the file COPYING. If not, write to
|
1995-06-15 14:29:51 +02:00
|
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
1995-06-15 14:30:13 +02:00
|
|
|
Boston, MA 02111-1307, USA. */
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Reference to the contents of an offset
|
|
|
|
(a value whose type is an OFFSET_TYPE).
|
|
|
|
Operand 0 is the object within which the offset is taken.
|
|
|
|
Operand 1 is the offset. The language independent OFFSET_REF
|
|
|
|
just won't work for us. */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (OFFSET_REF, "offset_ref", 'r', 2)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
1998-10-06 16:20:30 +02:00
|
|
|
/* A pointer-to-member constant. For a pointer-to-member constant
|
|
|
|
`X::Y' The PTRMEM_CST_CLASS is the RECORD_TYPE for `X' and the
|
|
|
|
PTRMEM_CST_MEMBER is the _DECL for `Y'. */
|
1999-09-07 18:07:42 +02:00
|
|
|
DEFTREECODE (PTRMEM_CST, "ptrmem_cst", 'c', 2)
|
1998-10-06 16:20:30 +02:00
|
|
|
|
1997-12-18 15:52:24 +01:00
|
|
|
/* For NEW_EXPR, operand 0 is the placement list.
|
|
|
|
Operand 1 is the new-declarator.
|
|
|
|
Operand 2 is the initializer. */
|
|
|
|
DEFTREECODE (NEW_EXPR, "nw_expr", 'e', 3)
|
|
|
|
DEFTREECODE (VEC_NEW_EXPR, "vec_nw_expr", 'e', 3)
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
/* For DELETE_EXPR, operand 0 is the store to be destroyed.
|
|
|
|
Operand 1 is the value to pass to the destroying function
|
|
|
|
saying whether the store should be deallocated as well. */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (DELETE_EXPR, "dl_expr", 'e', 2)
|
|
|
|
DEFTREECODE (VEC_DELETE_EXPR, "vec_dl_expr", 'e', 2)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
/* Value is reference to particular overloaded class method.
|
|
|
|
Operand 0 is the class name (an IDENTIFIER_NODE);
|
|
|
|
operand 1 is the field (also an IDENTIFIER_NODE).
|
|
|
|
The COMPLEXITY field holds the class level (usually 0). */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (SCOPE_REF, "scope_ref", 'r', 2)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
/* When composing an object with a member, this is the result.
|
|
|
|
Operand 0 is the object. Operand 1 is the member (usually
|
|
|
|
a dereferenced pointer to member). */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (MEMBER_REF, "member_ref", 'r', 2)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
|
|
|
/* Type conversion operator in C++. TREE_TYPE is type that this
|
|
|
|
operator converts to. Operand is expression to be converted. */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (TYPE_EXPR, "type_expr", 'e', 1)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
1997-12-18 15:52:24 +01:00
|
|
|
/* For AGGR_INIT_EXPR, operand 0 is function which performs initialization,
|
1994-02-24 02:02:37 +01:00
|
|
|
operand 1 is argument list to initialization function,
|
|
|
|
and operand 2 is the slot which was allocated for this expression. */
|
1997-12-19 02:27:33 +01:00
|
|
|
DEFTREECODE (AGGR_INIT_EXPR, "aggr_init_expr", 'e', 3)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
1994-05-06 11:27:46 +02:00
|
|
|
/* A throw expression. operand 0 is the expression, if there was one,
|
|
|
|
else it is NULL_TREE. */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (THROW_EXPR, "throw_expr", 'e', 1)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
1999-10-21 09:10:36 +02:00
|
|
|
/* 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)
|
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
/* 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.
|
|
|
|
DECL_ARGUMENTS template parm vector
|
|
|
|
DECL_TEMPLATE_INFO template text &c
|
|
|
|
DECL_VINDEX list of instantiations already produced;
|
|
|
|
only done for functions so far
|
|
|
|
For class template:
|
|
|
|
DECL_INITIAL associated templates (methods &c)
|
|
|
|
DECL_RESULT null
|
|
|
|
For non-class templates:
|
|
|
|
TREE_TYPE type of object to be constructed
|
|
|
|
DECL_RESULT decl for object to be created
|
|
|
|
(e.g., FUNCTION_DECL with tmpl parms used)
|
|
|
|
*/
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (TEMPLATE_DECL, "template_decl", 'd', 0)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
Support for friend templates.
* typeck.c (build_x_function_call): Handle static member function
templates like non-templates. Handle friend templates like normal
function templates.
* pt.c (tsubst, *_PARM): Don't use orig_level.
(get_bindings): Don't call add_to_template_args.
(instantiate_template): Likewise.
(tsubst, FUNCTION_DECL): Call add_to_template_args as appropriate.
* ptree.c (print_lang_type): Print index/level for template parms.
* Make-lang.in (cc1plus): Note that cc1plus depends on
cp/cp-tree.h and cp/cp-tree.def.
* cp-tree.def (TEMPLATE_CONST_PARM): Remove.
(TEMPLATE_PARM_INDEX): New tree code, used to indicate a
position in a template parameter list.
* cp-tree.h (template_parm_index): New structure, used as the tree
structure for a TEMPLATE_PARM_INDEX.
(TEMPLATE_PARM_IDX): New macro.
(TEMPLATE_PARM_LEVEL): Likewise.
(TEMPLATE_PARM_DESCENDANTS): Likewise.
(TEMPLATE_PARM_ORIG_LEVEL): Likewise.
(TEMPLATE_PARM_DECL): Likewise.
(TEMPLATE_TYPE_PARM_INDEX): Likewise.
(TEMPLATE_TYPE_ORIG_LEVEL): Likewise.
(TEMPLATE_TYPE_DECL): Likewise.
(TEMPLATE_CONST_IDX): Remove.
(TEMPLATE_CONST_LEVEL): Likewise.
(TEMPLATE_CONST_SET_INFO): Likewise.
(TEMPLATE_TYPE_SET_INFO): Likewise.
(TEMPLATE_TYPE_IDX): Redefine in terms of TEMPLATE_PARM_INDEX
node.
(TEMPLATE_TYPE_LEVEL): Likewise.
* decl.c (decls_match): Call comp_template_parms, rather than
expanding it inline.
(duplicate_decls): If two template declarations are being merged,
then their TEMPLATE_INFOs should be merged as well.
(grokfndecl): Save template-id information when declaring a friend
with explicit template arguments. Pass arguments to
check_explicit_specialization via correct convention; at some
point check_explicit_specialization changed, but these call-sites
did not.
(grokdeclarator): Tidy up slightly.
* decl2.c (check_classfn): Tidy up slightly. Don't assume that
two template functions with the same DECL_ASSEMBLER_NAME the same,
since the names are not yet mangled.
* error.c (dump_decl): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
(dump_expr): Likewise. Use the TEMPLATE_PARM_DECL to get at the
decl for a non-type parameter, rather than printing `<tparm ...>'.
* friend.c (is_friend): Handle TEMPLATE_DECL friends.
(do_friend): Deal with template friends.
* lex.c (do_pending_inlines): Call
maybe_begin_member_template_processing, rather than
conditionally calling begin_member_template_processing.
(process_next_inline): Likewise. Call
maybe_end_member_template_processing, rather than
conditionally calling end_member_template_processing.
(do_pending_defargs): Likewise.
(do_identifier): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
* method.c (build_mangled_template_parm_index): New function.
(build_overload_value): Use it.
(build_overload_name): Likewise.
* pt.c (finish_member_template_decl): Allow friend declarations.
(template_class_depth): New function.
(is_member_template): Rename, and modify, to become...
(is_member_or_friend_template): New function.
(end_member_template_processing): Rename, and modify, to become...
(maybe_end_member_template_processing).
(build_template_parm_index): New function.
(reduce_template_parm_level): New function.
(process_template_parm): Modify to use build_template_parm_index.
(current_template_args): Change name to current_template_parms.
(push_template_decl): Deal with friend templates.
(uses_template_parms): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
(tsubst_friend_function): New function.
(instantiate_class_template): Generate the DECL_FRIENDLIST
for a new instantiation by using tsubst_friend_function rather
than just tsubst.
(tsubst): Don't tsubst into a type which is a TEMPLATE_DECL.
Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM, and the
appropriate new macros. Use reduce_template_parm_level to
generate lower-level template parameters. Handle tsubst'ing into
TEMPLATE_DECLS that declare TEMPLATE_TEMPLATE_PARMS. Don't forget
to tsubst the DECL_CONTEXT and DECL_CLASS_CONTEXT of newly created
templates. Similarly for the template parameters for a new
template.
(tsubst_copy): Tidy up slightly. Use TEMPLATE_PARM_INDEX instead
of TEMPLATE_CONST_PARM. Handle TYPE_DECLs by tsubsting into them.
(unify): Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM.
(get_bindings): Call add_to_template_args if necessary.
(instantiate_decl): Handle instantiations of friend templates.
* search.c (lookup_field_1): Don't treat the TYPE_FIELDS of a
TEMPLATE_TYPE_PARM as a list of fields; it's not!
* spew.c (yylex): Do a little manual constant propogation to
clarify the code.
From-SVN: r18198
1998-02-23 04:17:44 +01:00
|
|
|
/* Index into a template parameter list. The TEMPLATE_PARM_IDX gives
|
|
|
|
the index (from 0) of the parameter, while the TEMPLATE_PARM_LEVEL
|
|
|
|
gives the level (from 1) of the parameter.
|
|
|
|
|
|
|
|
Here's an example:
|
|
|
|
|
|
|
|
template <class T> // Index 0, Level 1.
|
|
|
|
struct S
|
|
|
|
{
|
|
|
|
template <class U, // Index 0, Level 2.
|
|
|
|
class V> // Index 1, Level 2.
|
|
|
|
void f();
|
|
|
|
};
|
|
|
|
|
|
|
|
The DESCENDANTS will be a chain of TEMPLATE_PARM_INDEXs descended
|
|
|
|
from this one. The first descendant will have the same IDX, but
|
|
|
|
its LEVEL will be one less. The TREE_CHAIN field is used to chain
|
|
|
|
together the descendants. The TEMPLATE_PARM_DECL is the
|
|
|
|
declaration of this parameter, either a TYPE_DECL or CONST_DECL.
|
|
|
|
The TEMPLATE_PARM_ORIG_LEVEL is the LEVEL of the most distant
|
|
|
|
parent, i.e., the LEVEL that the parameter originally had when it
|
|
|
|
was declared. For example, if we instantiate S<int>, we will have:
|
|
|
|
|
|
|
|
struct S<int>
|
|
|
|
{
|
|
|
|
template <class U, // Index 0, Level 1, Orig Level 2
|
|
|
|
class V> // Index 1, Level 1, Orig Level 2
|
|
|
|
void f();
|
|
|
|
};
|
|
|
|
|
|
|
|
The LEVEL is the level of the parameter when we are worrying about
|
|
|
|
the types of things; the ORIG_LEVEL is the level when we are
|
|
|
|
worrying about instantiating things. */
|
1998-03-30 12:56:25 +02:00
|
|
|
DEFTREECODE (TEMPLATE_PARM_INDEX, "template_parm_index", 'x',
|
1999-12-15 10:18:21 +01:00
|
|
|
/* The addition of (sizeof(tree) - 1) in the next expression
|
|
|
|
is to handle the case when padding pushes us past an even
|
|
|
|
multiple of sizeof(tree). */
|
|
|
|
/* We used to try to calculate this using
|
|
|
|
1+3*sizeof(HOST_WIDE_INT), but that fails if alignment
|
|
|
|
makes it bigger. */
|
|
|
|
((sizeof (template_parm_index) - sizeof (struct tree_common))
|
|
|
|
+ sizeof (tree) - 1)
|
|
|
|
/ sizeof (tree))
|
Support for friend templates.
* typeck.c (build_x_function_call): Handle static member function
templates like non-templates. Handle friend templates like normal
function templates.
* pt.c (tsubst, *_PARM): Don't use orig_level.
(get_bindings): Don't call add_to_template_args.
(instantiate_template): Likewise.
(tsubst, FUNCTION_DECL): Call add_to_template_args as appropriate.
* ptree.c (print_lang_type): Print index/level for template parms.
* Make-lang.in (cc1plus): Note that cc1plus depends on
cp/cp-tree.h and cp/cp-tree.def.
* cp-tree.def (TEMPLATE_CONST_PARM): Remove.
(TEMPLATE_PARM_INDEX): New tree code, used to indicate a
position in a template parameter list.
* cp-tree.h (template_parm_index): New structure, used as the tree
structure for a TEMPLATE_PARM_INDEX.
(TEMPLATE_PARM_IDX): New macro.
(TEMPLATE_PARM_LEVEL): Likewise.
(TEMPLATE_PARM_DESCENDANTS): Likewise.
(TEMPLATE_PARM_ORIG_LEVEL): Likewise.
(TEMPLATE_PARM_DECL): Likewise.
(TEMPLATE_TYPE_PARM_INDEX): Likewise.
(TEMPLATE_TYPE_ORIG_LEVEL): Likewise.
(TEMPLATE_TYPE_DECL): Likewise.
(TEMPLATE_CONST_IDX): Remove.
(TEMPLATE_CONST_LEVEL): Likewise.
(TEMPLATE_CONST_SET_INFO): Likewise.
(TEMPLATE_TYPE_SET_INFO): Likewise.
(TEMPLATE_TYPE_IDX): Redefine in terms of TEMPLATE_PARM_INDEX
node.
(TEMPLATE_TYPE_LEVEL): Likewise.
* decl.c (decls_match): Call comp_template_parms, rather than
expanding it inline.
(duplicate_decls): If two template declarations are being merged,
then their TEMPLATE_INFOs should be merged as well.
(grokfndecl): Save template-id information when declaring a friend
with explicit template arguments. Pass arguments to
check_explicit_specialization via correct convention; at some
point check_explicit_specialization changed, but these call-sites
did not.
(grokdeclarator): Tidy up slightly.
* decl2.c (check_classfn): Tidy up slightly. Don't assume that
two template functions with the same DECL_ASSEMBLER_NAME the same,
since the names are not yet mangled.
* error.c (dump_decl): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
(dump_expr): Likewise. Use the TEMPLATE_PARM_DECL to get at the
decl for a non-type parameter, rather than printing `<tparm ...>'.
* friend.c (is_friend): Handle TEMPLATE_DECL friends.
(do_friend): Deal with template friends.
* lex.c (do_pending_inlines): Call
maybe_begin_member_template_processing, rather than
conditionally calling begin_member_template_processing.
(process_next_inline): Likewise. Call
maybe_end_member_template_processing, rather than
conditionally calling end_member_template_processing.
(do_pending_defargs): Likewise.
(do_identifier): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
* method.c (build_mangled_template_parm_index): New function.
(build_overload_value): Use it.
(build_overload_name): Likewise.
* pt.c (finish_member_template_decl): Allow friend declarations.
(template_class_depth): New function.
(is_member_template): Rename, and modify, to become...
(is_member_or_friend_template): New function.
(end_member_template_processing): Rename, and modify, to become...
(maybe_end_member_template_processing).
(build_template_parm_index): New function.
(reduce_template_parm_level): New function.
(process_template_parm): Modify to use build_template_parm_index.
(current_template_args): Change name to current_template_parms.
(push_template_decl): Deal with friend templates.
(uses_template_parms): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
(tsubst_friend_function): New function.
(instantiate_class_template): Generate the DECL_FRIENDLIST
for a new instantiation by using tsubst_friend_function rather
than just tsubst.
(tsubst): Don't tsubst into a type which is a TEMPLATE_DECL.
Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM, and the
appropriate new macros. Use reduce_template_parm_level to
generate lower-level template parameters. Handle tsubst'ing into
TEMPLATE_DECLS that declare TEMPLATE_TEMPLATE_PARMS. Don't forget
to tsubst the DECL_CONTEXT and DECL_CLASS_CONTEXT of newly created
templates. Similarly for the template parameters for a new
template.
(tsubst_copy): Tidy up slightly. Use TEMPLATE_PARM_INDEX instead
of TEMPLATE_CONST_PARM. Handle TYPE_DECLs by tsubsting into them.
(unify): Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM.
(get_bindings): Call add_to_template_args if necessary.
(instantiate_decl): Handle instantiations of friend templates.
* search.c (lookup_field_1): Don't treat the TYPE_FIELDS of a
TEMPLATE_TYPE_PARM as a list of fields; it's not!
* spew.c (yylex): Do a little manual constant propogation to
clarify the code.
From-SVN: r18198
1998-02-23 04:17:44 +01:00
|
|
|
|
1994-02-24 02:02:37 +01:00
|
|
|
/* Index into a template parameter list. This parameter must be a type.
|
Support for friend templates.
* typeck.c (build_x_function_call): Handle static member function
templates like non-templates. Handle friend templates like normal
function templates.
* pt.c (tsubst, *_PARM): Don't use orig_level.
(get_bindings): Don't call add_to_template_args.
(instantiate_template): Likewise.
(tsubst, FUNCTION_DECL): Call add_to_template_args as appropriate.
* ptree.c (print_lang_type): Print index/level for template parms.
* Make-lang.in (cc1plus): Note that cc1plus depends on
cp/cp-tree.h and cp/cp-tree.def.
* cp-tree.def (TEMPLATE_CONST_PARM): Remove.
(TEMPLATE_PARM_INDEX): New tree code, used to indicate a
position in a template parameter list.
* cp-tree.h (template_parm_index): New structure, used as the tree
structure for a TEMPLATE_PARM_INDEX.
(TEMPLATE_PARM_IDX): New macro.
(TEMPLATE_PARM_LEVEL): Likewise.
(TEMPLATE_PARM_DESCENDANTS): Likewise.
(TEMPLATE_PARM_ORIG_LEVEL): Likewise.
(TEMPLATE_PARM_DECL): Likewise.
(TEMPLATE_TYPE_PARM_INDEX): Likewise.
(TEMPLATE_TYPE_ORIG_LEVEL): Likewise.
(TEMPLATE_TYPE_DECL): Likewise.
(TEMPLATE_CONST_IDX): Remove.
(TEMPLATE_CONST_LEVEL): Likewise.
(TEMPLATE_CONST_SET_INFO): Likewise.
(TEMPLATE_TYPE_SET_INFO): Likewise.
(TEMPLATE_TYPE_IDX): Redefine in terms of TEMPLATE_PARM_INDEX
node.
(TEMPLATE_TYPE_LEVEL): Likewise.
* decl.c (decls_match): Call comp_template_parms, rather than
expanding it inline.
(duplicate_decls): If two template declarations are being merged,
then their TEMPLATE_INFOs should be merged as well.
(grokfndecl): Save template-id information when declaring a friend
with explicit template arguments. Pass arguments to
check_explicit_specialization via correct convention; at some
point check_explicit_specialization changed, but these call-sites
did not.
(grokdeclarator): Tidy up slightly.
* decl2.c (check_classfn): Tidy up slightly. Don't assume that
two template functions with the same DECL_ASSEMBLER_NAME the same,
since the names are not yet mangled.
* error.c (dump_decl): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
(dump_expr): Likewise. Use the TEMPLATE_PARM_DECL to get at the
decl for a non-type parameter, rather than printing `<tparm ...>'.
* friend.c (is_friend): Handle TEMPLATE_DECL friends.
(do_friend): Deal with template friends.
* lex.c (do_pending_inlines): Call
maybe_begin_member_template_processing, rather than
conditionally calling begin_member_template_processing.
(process_next_inline): Likewise. Call
maybe_end_member_template_processing, rather than
conditionally calling end_member_template_processing.
(do_pending_defargs): Likewise.
(do_identifier): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
* method.c (build_mangled_template_parm_index): New function.
(build_overload_value): Use it.
(build_overload_name): Likewise.
* pt.c (finish_member_template_decl): Allow friend declarations.
(template_class_depth): New function.
(is_member_template): Rename, and modify, to become...
(is_member_or_friend_template): New function.
(end_member_template_processing): Rename, and modify, to become...
(maybe_end_member_template_processing).
(build_template_parm_index): New function.
(reduce_template_parm_level): New function.
(process_template_parm): Modify to use build_template_parm_index.
(current_template_args): Change name to current_template_parms.
(push_template_decl): Deal with friend templates.
(uses_template_parms): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
(tsubst_friend_function): New function.
(instantiate_class_template): Generate the DECL_FRIENDLIST
for a new instantiation by using tsubst_friend_function rather
than just tsubst.
(tsubst): Don't tsubst into a type which is a TEMPLATE_DECL.
Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM, and the
appropriate new macros. Use reduce_template_parm_level to
generate lower-level template parameters. Handle tsubst'ing into
TEMPLATE_DECLS that declare TEMPLATE_TEMPLATE_PARMS. Don't forget
to tsubst the DECL_CONTEXT and DECL_CLASS_CONTEXT of newly created
templates. Similarly for the template parameters for a new
template.
(tsubst_copy): Tidy up slightly. Use TEMPLATE_PARM_INDEX instead
of TEMPLATE_CONST_PARM. Handle TYPE_DECLs by tsubsting into them.
(unify): Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM.
(get_bindings): Call add_to_template_args if necessary.
(instantiate_decl): Handle instantiations of friend templates.
* search.c (lookup_field_1): Don't treat the TYPE_FIELDS of a
TEMPLATE_TYPE_PARM as a list of fields; it's not!
* spew.c (yylex): Do a little manual constant propogation to
clarify the code.
From-SVN: r18198
1998-02-23 04:17:44 +01:00
|
|
|
The TYPE_FIELDS value will be a TEMPLATE_PARM_INDEX. */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", 't', 0)
|
1994-02-24 02:02:37 +01:00
|
|
|
|
2000-06-23 08:49:45 +02:00
|
|
|
/* Index into a template parameter list for template template parameters.
|
|
|
|
This parameter must be a type. The TYPE_FIELDS value will be a
|
|
|
|
TEMPLATE_PARM_INDEX.
|
|
|
|
|
2000-09-05 03:01:39 +02:00
|
|
|
It is used without template arguments like TT in C<TT>,
|
2000-06-23 08:49:45 +02:00
|
|
|
TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO is NULL_TREE
|
2000-09-05 03:01:39 +02:00
|
|
|
and TYPE_NAME is a TEMPLATE_DECL. */
|
|
|
|
DEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", 't', 0)
|
2000-06-23 08:49:45 +02:00
|
|
|
|
2000-09-05 03:01:39 +02:00
|
|
|
/* Like TEMPLATE_TEMPLATE_PARM it is used with bound template arguments
|
|
|
|
like TT<int>.
|
2000-08-12 04:09:28 +02:00
|
|
|
In this case, TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO contains the
|
|
|
|
template name and its bound arguments. TYPE_NAME is a TYPE_DECL. */
|
2000-09-05 03:01:39 +02:00
|
|
|
DEFTREECODE (BOUND_TEMPLATE_TEMPLATE_PARM, "bound_template_template_parm", 't', 0)
|
pt.c (coerce_template_parms): Don't access elements of ARGLIST that is not really present.
Wed Jan 21 10:29:57 1998 Kriang Lerdsuwanakij <lerdsuwa@scf.usc.edu>
* pt.c (coerce_template_parms): Don't access elements of ARGLIST
that is not really present. Substitute default arguments in
template template arguments. Correctly convert TEMPLATE_DECL to
TEMPLATE_TEMPLATE_PARM.
(comp_template_args): TEMPLATE_DECL and TEMPLATE_TEMPLATE_PARM
are no longer treated specially here.
* parse.y (template_template_parm): Fix copy error.
* decl.c (grokdeclarator): Warn about missing `typename' for nested
type created from template template parameters.
* parse.y (bad_parm): Likewise
* class.c (finish_struct): Handle TEMPLATE_TEMPLATE_PARM.
(push_nested_class): Likewise.
* cp-tree.def (TEMPLATE_TEMPLATE_PARM): New tree code.
* cp-tree.h (DECL_TEMPLATE_TEMPLATE_PARM_P): New macro.
(copy_template_template_parm): Declare.
* decl.c (arg_looking_for_template): New variable.
(lookup_name_real): Handle TEMPLATE_TEMPLATE_PARM.
Try to return TEMPLATE_DECL or TEMPLATE_TEMPLATE_PARM
node if arg_looking_for_template is nonzero.
(pushdecl): Handle TEMPLATE_TEMPLATE_PARM.
(grok_op_properties, xref_tag, xref_basetypes): Likewise.
(grokdeclarator): Handle TEMPLATE_DECL.
* decl2.c (constructor_name_full): Handle TEMPLATE_TEMPLATE_PARM.
* error.c (dump_type): Add TEMPLATE_DECL and TEMPLATE_TEMPLATE_PARM.
(dump_type_prefix, dump_type_suffix) Handle TEMPLATE_TEMPLATE_PARM.
(dump_decl): Handle unnamed template type parameters.
Handle template template parameters.
(dump_function_name): Handle template template parameters.
* init.c (is_aggr_typedef, is_aggr_type, get_aggr_from_typedef):
Handle TEMPLATE_TEMPLATE_PARM.
* method.c (build_template_template_parm_names): New function.
(build_template_parm_names): Handle TEMPLATE_DECL.
(build_overload_nested_name, build_overload_name):
Handle TEMPLATE_TEMPLATE_PARM.
* parse.y (maybe_identifier): New nonterminal.
(template_type_parm): Use it.
(template_template_parm, template_arg1): New nonterminal.
(template_parm): Add template_template_parm rules.
(template_arg): Set processing_template_arg.
(template_arg1): Rules moved from template_arg.
(primary, nonnested_type): Set arg_looking_for_template if we are
processing template arguments.
* pt.c (begin_member_template_processing): Handle TEMPLATE_DECL.
(process_template_parm): Handle template template parameters.
(coerce_template_parms, comp_template_args): Likewise.
(mangle_class_name_for_template, lookup_template_class): Likewise.
(uses_template_parms): Handle TEMPLATE_DECL and
TEMPLATE_TEMPLATE_PARM.
(current_template_args): Handle TEMPLATE_DECL.
(tsubst, tsubst_copy, unify): Handle TEMPLATE_TEMPLATE_PARM.
* search.c (dfs_walk, dfs_record_inheritance):
Handle TEMPLATE_TEMPLATE_PARM.
* tree.c (copy_template_template_parm): New function.
(mapcar): Handle TEMPLATE_TEMPLATE_PARM.
* typeck.c (comptypes): Handle TEMPLATE_TEMPLATE_PARM.
From-SVN: r17441
1998-01-22 12:03:56 +01:00
|
|
|
|
1998-10-15 13:27:43 +02:00
|
|
|
/* A type designated by `typename T::t'. TYPE_CONTEXT is `T',
|
1999-04-16 20:06:34 +02:00
|
|
|
TYPE_NAME is an IDENTIFIER_NODE for `t'. If the type was named via
|
|
|
|
template-id, TYPENAME_TYPE_FULLNAME will hold the TEMPLATE_ID_EXPR.
|
|
|
|
If TREE_TYPE is present, this type was generated by the implicit
|
|
|
|
typename extension, and the TREE_TYPE is a _TYPE from a baseclass
|
|
|
|
of `T'. */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (TYPENAME_TYPE, "typename_type", 't', 0)
|
1996-02-28 23:01:56 +01:00
|
|
|
|
1998-10-26 03:07:50 +01:00
|
|
|
/* A type designated by `__typeof (expr)'. TYPE_FIELDS is the
|
|
|
|
expression in question. */
|
|
|
|
DEFTREECODE (TYPEOF_TYPE, "typeof_type", 't', 0)
|
|
|
|
|
1996-02-20 21:35:10 +01:00
|
|
|
/* A using declaration. DECL_INITIAL contains the specified scope.
|
|
|
|
This is not an alias, but is later expanded into multiple aliases. */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (USING_DECL, "using_decl", 'd', 0)
|
1996-02-28 23:01:56 +01:00
|
|
|
|
1997-07-24 23:09:25 +02:00
|
|
|
/* An un-parsed default argument. Looks like an IDENTIFIER_NODE. */
|
2001-01-05 12:41:27 +01:00
|
|
|
DEFTREECODE (DEFAULT_ARG, "default_arg", 'x', 2)
|
1997-07-24 23:09:25 +02:00
|
|
|
|
tinfo.h (__class_type_info): Fix illegal declaration.
1999-04-02 Mark Mitchell <mark@codesourcery.com>
* tinfo.h (__class_type_info): Fix illegal declaration.
* cp-tree.def (TEMPLATE_ID_EXPR): Update comment.
* cp-tree.h (INHERITED_VALUE_BINDING_P): New macro.
(IDENTIFIER_CLASS_VALUE): Improve documentation.
(is_properly_derived_from): Declare.
(invalidate_class_lookup_cache): Likewise.
(maybe_maybe_note_name_used_in_class): Likewise.
(note_name_declared_in_class): Likewise.
(push_using_decl): Remove duplicate declaration.
(id_in_current_class): Remove declaration.
(push_class_binding): Change prototype.
(clear_identitifer_class_values): Declare.
* call.c (is_properly_derived_from): Make it global.
(build_new_function_call): Be careful about updating candidates.
(build_new_method_call): Handle COMPONENT_REFs. Don't crash when
asked to make illegal calls.
* class.c: Include splay-tree.h.
(class_stack_node): Add names_used slot.
(check_member_decl_is_same_in_complete_scope): Remove.
(add_method): Fix comment. Push the declaration into class
scope.
(finish_struct_1): When popping the class, pop the bindings too.
Remove check for data member/function member conflict.
(finish_struct): Remove calls to
check_member_decl_is_same_in_complete_scope. Change calls to
popclass.
(pushclass): Clear names_used in the class stack entry.
Use invalidate_class_lookup_cache to remove cached entries, rather
than magic values with popclass. Clear IDENTIFIER_CLASS_VALUE
before entering a new class. Remove dead code. Don't mess with
current_function_decl when pushing declarations.
(invalidate_class_lookup_cache): New function, split out from ...
(popclass): Here. Clean up names_used on our way out.
(instantiate_type): Adjust.
(build_self_reference): Don't push the declaration here.
(maybe_note_name_used_in_class): New function.
(note_name_declared_in_class): Likewise.
* decl.c (add_binding): Change prototype.
(find_class_binding_level): New function.
(innermost_nonclass_level): Likewise.
(current_binding_level): Update documentation.
(inner_binding_level): Remove. Replace with current_binding_level
throughout.
(push_binding_level): Remove special handling of
class_binding_level.
(pop_binding_level): Likewise. Use find_class_binding_level.
(suspend_binding_level): Likewise.
(global_bindings_p): Use innermost_nonclass_level.
(toplevel_bindings_p): Likewise.
(namespace_bindings_p): Likewise.
(pseudo_global_level_p): Likewise.
(push_binding): Clear INHERITED_VALUE_BINDING_P.
(add_binding): Check for illegal multiple declarations. Return a
value indicating whether or not the new binding was legal.
(push_local_binding): Skip over class binding levels. Check
return value from add_binding.
(push_class_binding): Set INHERITED_VALUE_BINDING_P. Call
note_name_declared_in_class.
(pushlevel_class): Remove "fake out the rest of the compiler"
code.
(poplevel_class): Reset IDENTIFIER_CLASS_VALUEs.
(clear_identifier_class_values): New function.
(pop_from_top_level): Use it.
(pop_everything): Tweak.
(maybe_process_template_type_declaration): Don't push the
declaration for the template here.
(pushtag): Don't push tag declarations into class scope here.
(pushdecl): Apply DeMorgan's law for readability.
(pushdecl_class_level): Remove special-case code for
TYPE_BEING_DEFINED. Handle OVERLOADs and anonymous unions.
(push_class_level_bindng): Deal with inherited bindings.
(lookup_name_real): Remove special-case code for
TYPE_BEING_DEFINED, and some implicit typename magic.
(grokdeclarator): Handle COMPONENT_REF for a template function.
(build_enumerator): Don't call pushdecl_class_level here.
(id_in_current_class): Remove.
* decl2.c (grokfield): Don't call pushdecl_class_level or
check_template_shadow.
* errfn.c (cp_file_of): Don't declare.
(cp_line_of): Likewise.
* error.c (dump_decl): Handle an OVERLOAD.
(cp_file_of): Likewise.
(cp_line_of): Likewise.
* init.c (build_member_call): Handle a COMPONENT_REF.
* lex.c (do_identifier): Call maybe_note_name_used_in_class, not
pushdecl_class_level.
* method.c (hack_identifier): Build COMPONENT_REFs for references
to member templates as well as member functions. Remove dead
code.
* parse.y (left_curly): Remove.
(nonnested_type): Call maybe_note_name_used_in_class, not
pushdecl_class_level.
* parse.c: Regenerated.
(nested_name_specifier_1): Likewise.
* pt.c (check_explicit_specialization): Adjust, for robustness.
(check_template_shadow): Handle OVERLOADs.
(build_template_decl): Set DECL_CONSTRUCTOR_P on the
TEMPLATE_DECL, if appropriate.
* search.c (envelope_add_decl): Remove.
(dfs_pushdecls): Likewise.
(dfs_compress_decls): Likewise.
(dfs_push_decls): New function.
(dfs_push_type_decls): Likewise.
(setup_class_bindings): Likewise.
(template_self_reference_p): Likewise.
(lookup_field_r): Use it.
(looup_member): Remove old comment. Deal with ambiguity.
(push_class_decls): Use dfs_push_decls and dfs_push_type_decls,
and remove envelope processing.
* semantics.c (begin_class_definition): Let pushclass push
declarations for base classes.
(finish_member_declaration): Push declarations into class scope.
* typeck.c (build_component_ref): Just put an OVERLOAD into the
COMPONENT_REF, not a TREE_LIST of an OVERLOAD.
(build_x_function_call): Deal with OVERLOAD. Handle template-ids.
* Makefile.in (class.o): Depend on splay-tree.h.
From-SVN: r26133
1999-04-02 17:36:57 +02:00
|
|
|
/* A template-id, like foo<int>. The first operand is the template.
|
1999-05-17 18:07:39 +02:00
|
|
|
The second is the TREE_LIST or TREE_VEC of explicitly specified
|
|
|
|
arguments. The template will be a FUNCTION_DECL, TEMPLATE_DECL, or
|
|
|
|
an OVERLOAD. If the template-id refers to a member template, the
|
|
|
|
template may be an IDENTIFIER_NODE. */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", 'e', 2)
|
1997-09-28 21:16:59 +02:00
|
|
|
|
1998-12-13 15:46:07 +01:00
|
|
|
/* An association between name and entity. Parameters are the scope
|
|
|
|
and the (non-type) value. TREE_TYPE indicates the type bound to
|
|
|
|
the name. */
|
Partial implementation of namespaces.
* decl.c (push_namespace): Handle redeclaration error.
* cp-tree.h (IDENTIFIER_NAMESPACE_VALUE): New macro.
(IDENTIFIER_NAMESPACE_BINDINGS): New macro.
(NAMESPACE_BINDING): New macro.
(IDENTIFIER_GLOBAL_VALUE): Use NAMESPACE_BINDING.
* *.c: Use them.
* pt.c (push_template_decl): Use innermost_args.
* decl.c (get_unique_name): Tweak from earlier in the name.
* cp-tree.def: Add CPLUS_BINDING node.
* cp-tree.h (tree_binding): new struct
(BINDING_SCOPE, BINDING_VALUE): new macros
(current_namespace, global_namespace): declare extern
(struct lang_decl_flags): new field in_namespace
(DECL_NAMESPACE_USING, DECL_NAMESPACE_USERS): new macros
(DECL_NAMESPACE, SET_DECL_NAMESPACE): new macros
(TREE_INDIRECT_USING): new macro
* decl2.c (current_namespace, global_namespace): Declare. The
value is a NAMESPACE_DECL now, not a TREE_LIST.
(is_namespace_ancestor, namespace_ancestor):new static functions.
(add_using_namespace, ambiguous_decl): likewise.
(lookup_using_namespace): new support function for lookup_name.
(qualified_lookup_using_namespace): new support function for
do_scoped_id and lookup_namespace_name
(get_namespace_id): mark as obsolete.
(current_namespace_id): Likewise.
(do_namespace_alias): Implement.
(do_using_directive): Implement as call to add_using_namespace.
* decl.c (binding_for_name): new function.
(push_namespace, pop_namespace): implement.
(push_decl): don't install a FUNCTION_DECL in the global branch.
(lookup_namespace_name): implement using qualified lookup.
(lookup_name_real): For global scoping, lookup in
global_namespace. For namespace scoping, lookup in given
namespace. For unscoped lookup, iterate over namespace,
considering using directives.
(init_decl_processing): initialize global_namespace.
(grokvardecl): Build assembler name as static name for globals.
(grokdeclarator): Remove old namespace mangling.
(xref_tag): When installing a global binding for the
tag, make sure we have an identifier.
* method.c (build_overload_nested_name): mangle namespaces.
(build_qualified_name): Likewise.
(build_decl_overload_real): Likewise.
* lex.c (build_lang_decl): set namespace for new declaration to
current_namespace.
(do_scoped_id): find global names in global or current
namespace, or using qualified namespace lookup, depending on
context.
* init.c (build_member_call): When scope is namespace, use
build_x_function_call instead.
(build_offset_ref): When scope is namespace, collapse processing
to lookup_namespace_name instead.
* error.c (dump_decl): Support NAMESPACE_DECL.
* decl.c (pushdecl): Bind globals to current namespace.
(push_overloaded_decl): Likewise.
(lookup_tag): Likewise.
(lookup_name_current_level): Likewise.
(xref_tag): Likewise.
(start_function): Likewise.
* lex.c (do_identifier): Likewise.
(identifier_typedecl_value): Likewise.
(real_yylex): Likewise.
* method.c (do_inline_function_hair): Likewise.
* parse.y (unscoped): Likewise.
* pt.c (check_explicit_specialization): Likewise.
(lookup_template_class): Likewise.
* rtti.c (call_void_fn): Likewise.
* sig.c (build_sigtable): Likewise.
* ptree.c (lang_print_xnode): New function.
From-SVN: r18227
1998-02-25 01:49:51 +01:00
|
|
|
DEFTREECODE (CPLUS_BINDING, "binding", 'x', 2)
|
|
|
|
|
1998-05-08 04:06:26 +02:00
|
|
|
/* A list-like node for chaining overloading candidates. TREE_TYPE is
|
|
|
|
the original name, and the parameter is the FUNCTION_DECL. */
|
|
|
|
DEFTREECODE (OVERLOAD, "overload", 'x', 1)
|
|
|
|
|
1998-04-24 00:26:41 +02:00
|
|
|
/* A generic wrapper for something not tree that we want to include in
|
|
|
|
tree structure. */
|
|
|
|
DEFTREECODE (WRAPPER, "wrapper", 'x', 1)
|
|
|
|
|
1998-08-02 23:37:23 +02:00
|
|
|
/* Used to represent deferred name lookup for dependent names while
|
|
|
|
parsing a template declaration. The first argument is an
|
|
|
|
IDENTIFIER_NODE for the name in question. The TREE_TYPE is
|
|
|
|
unused. */
|
|
|
|
DEFTREECODE (LOOKUP_EXPR, "lookup_expr", 'e', 1)
|
|
|
|
|
1999-11-23 03:49:41 +01:00
|
|
|
/* Used to represent __PRETTY_FUNCTION__ in template bodies. */
|
|
|
|
DEFTREECODE (FUNCTION_NAME, "function_name", 'e', 0)
|
|
|
|
|
1997-07-24 23:09:25 +02:00
|
|
|
/* A whole bunch of tree codes for the initial, superficial parsing of
|
|
|
|
templates. */
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (MODOP_EXPR, "modop_expr", 'e', 3)
|
|
|
|
DEFTREECODE (CAST_EXPR, "cast_expr", '1', 1)
|
|
|
|
DEFTREECODE (REINTERPRET_CAST_EXPR, "reinterpret_cast_expr", '1', 1)
|
|
|
|
DEFTREECODE (CONST_CAST_EXPR, "const_cast_expr", '1', 1)
|
|
|
|
DEFTREECODE (STATIC_CAST_EXPR, "static_cast_expr", '1', 1)
|
|
|
|
DEFTREECODE (DYNAMIC_CAST_EXPR, "dynamic_cast_expr", '1', 1)
|
|
|
|
DEFTREECODE (DOTSTAR_EXPR, "dotstar_expr", 'e', 2)
|
|
|
|
DEFTREECODE (TYPEID_EXPR, "typeid_expr", 'e', 1)
|
1999-08-19 10:06:17 +02:00
|
|
|
DEFTREECODE (PSEUDO_DTOR_EXPR, "pseudo_dtor_expr", 'e', 3)
|
1997-12-12 07:49:29 +01:00
|
|
|
|
1999-08-26 00:07:18 +02:00
|
|
|
/* A SUBOBJECT statement marks the point at which a sub-object is
|
|
|
|
fully constructed. After this point, the SUBOBJECT_CLEANUP must be
|
|
|
|
run if an exception is thrown before the end of the enclosing
|
|
|
|
function. */
|
|
|
|
DEFTREECODE (SUBOBJECT, "subobject", 'e', 1)
|
Make-lang.in (CXX_SRCS): Add optimize.c.
1999-11-25 Mark Mitchell <mark@codesourcery.com>
* Make-lang.in (CXX_SRCS): Add optimize.c.
* Makefile.in (CXX_OBJS): Add optimize.o.
(CXX_TREE_H): Add splay-tree.h, system.h, and $(CONFIG_H).
(spew.o, lex.o, decl.o, decl2.o, typeck2.o, typeck.o): Adjust.
(class.o, call.o, friend.o, init.o, method.o, cvt.o): Likewise.
(search.o, tree.o, ptree.o, rtti.o, except.o, expr.o): Likewise.
(xref.o, pt.o, error.o, errfn.o, repo.o, semantics.o): Likewise.
(dump.o): Likewise.
(optimize.o): New target.
* class.c: Don't include splay-tree.h.
* cp-tree.def (CTOR_COMPLETE): Rename to CTOR_STMT.
* cp-tree.h: Include splay-tree.h.
(DECL_UNINLINABLE): New macro.
(CTOR_BEGIN_P, CTOR_END_P): New macros.
(flag_inline_trees): New variable.
(local_variable_p): New function.
(nonstatic_local_decl_p): Likewise.
(optimize_function): Likewise.
(cplus_unsave_expr_now): Remove.
(copy_tree_r): Declare.
(remap_save_expr): Likewise.
* decl.c (local_variable_p): Don't
make it static.
(local_variable_p_walkfn): New function.
(make_rtl_for_local_static): Remove code to try to avoid writing
out static constants.
(emit_local_var): Fix indentation.
(nonstatic_local_decl_p): New function.
(check_default_argument): Use local_variable_p_walkfn, not
local_variable_p, when walking the tree.
(start_function): Set the DECL_CONTEXT for automatically generated
labels.
(finish_constructor_body): Use CTOR_STMT to mark the end of a
constructor.
* decl2.c: Don't include splay-tree.h.
(flag_inline_trees): Define.
* dump.c: Don't include
splay-tree.h.
* except.c (expand_end_catch_block): Fix comment formatting.
(expand_end_eh_spec): Set DECL_CONTEXT on temporary variables.
(expand_throw): Tidy comment.
* init.c (build_vec_delete_1): Use create_temporary_var.
* lex.c (cplus_tree_code_type): Make it static.
(cplus_tree_code_length): Likewise.
(cplus_tree_code_name): Likewise.
* optimize.c: New file.
* semantics.c (finish_goto_stmt): Set DECL_UNLINABLE for functions
with computed gotos.
(setup_vtbl_ptr): Mark the beginnings of constructors with
CTOR_STMT.
(expand_stmt): Handle CTOR_STMT, not CTOR_COMPLETE.
(expand_body): Call optimize_function. Save bodies if we're doing
inlining on trees.
* tree.c: Don't include splay-tree.h. Include insn-config.h and
integrate.h.
(copy_tree_r): Make it public.
(statement_code_p): New function.
(mark_local_for_remap_r): Likewise.
(cp_usave_r): Likewise.
(cp_unsave): Likewise.
(build_cplus_new): Set DECL_CONTEXT for temporary variables.
(walk_tree): Walk into `s' class nodes. Walk statement chains.
(copy_tree_r): Handle 's' class nodes. Restore chains for
statements. Nullify scopes. Don't copy types.
(init_tree): Set lang_unsave to cp_unsave.
(remap_save_expr): Define.
* ir.texi: Document CTOR_STMT.
From-SVN: r30669
1999-11-25 21:32:04 +01:00
|
|
|
/* An CTOR_STMT marks the beginning (if CTOR_BEGIN_P holds) or end of
|
2000-08-30 12:20:22 +02:00
|
|
|
a constructor (if CTOR_END_P) holds. At the end of a constructor,
|
Make-lang.in (CXX_SRCS): Add optimize.c.
1999-11-25 Mark Mitchell <mark@codesourcery.com>
* Make-lang.in (CXX_SRCS): Add optimize.c.
* Makefile.in (CXX_OBJS): Add optimize.o.
(CXX_TREE_H): Add splay-tree.h, system.h, and $(CONFIG_H).
(spew.o, lex.o, decl.o, decl2.o, typeck2.o, typeck.o): Adjust.
(class.o, call.o, friend.o, init.o, method.o, cvt.o): Likewise.
(search.o, tree.o, ptree.o, rtti.o, except.o, expr.o): Likewise.
(xref.o, pt.o, error.o, errfn.o, repo.o, semantics.o): Likewise.
(dump.o): Likewise.
(optimize.o): New target.
* class.c: Don't include splay-tree.h.
* cp-tree.def (CTOR_COMPLETE): Rename to CTOR_STMT.
* cp-tree.h: Include splay-tree.h.
(DECL_UNINLINABLE): New macro.
(CTOR_BEGIN_P, CTOR_END_P): New macros.
(flag_inline_trees): New variable.
(local_variable_p): New function.
(nonstatic_local_decl_p): Likewise.
(optimize_function): Likewise.
(cplus_unsave_expr_now): Remove.
(copy_tree_r): Declare.
(remap_save_expr): Likewise.
* decl.c (local_variable_p): Don't
make it static.
(local_variable_p_walkfn): New function.
(make_rtl_for_local_static): Remove code to try to avoid writing
out static constants.
(emit_local_var): Fix indentation.
(nonstatic_local_decl_p): New function.
(check_default_argument): Use local_variable_p_walkfn, not
local_variable_p, when walking the tree.
(start_function): Set the DECL_CONTEXT for automatically generated
labels.
(finish_constructor_body): Use CTOR_STMT to mark the end of a
constructor.
* decl2.c: Don't include splay-tree.h.
(flag_inline_trees): Define.
* dump.c: Don't include
splay-tree.h.
* except.c (expand_end_catch_block): Fix comment formatting.
(expand_end_eh_spec): Set DECL_CONTEXT on temporary variables.
(expand_throw): Tidy comment.
* init.c (build_vec_delete_1): Use create_temporary_var.
* lex.c (cplus_tree_code_type): Make it static.
(cplus_tree_code_length): Likewise.
(cplus_tree_code_name): Likewise.
* optimize.c: New file.
* semantics.c (finish_goto_stmt): Set DECL_UNLINABLE for functions
with computed gotos.
(setup_vtbl_ptr): Mark the beginnings of constructors with
CTOR_STMT.
(expand_stmt): Handle CTOR_STMT, not CTOR_COMPLETE.
(expand_body): Call optimize_function. Save bodies if we're doing
inlining on trees.
* tree.c: Don't include splay-tree.h. Include insn-config.h and
integrate.h.
(copy_tree_r): Make it public.
(statement_code_p): New function.
(mark_local_for_remap_r): Likewise.
(cp_usave_r): Likewise.
(cp_unsave): Likewise.
(build_cplus_new): Set DECL_CONTEXT for temporary variables.
(walk_tree): Walk into `s' class nodes. Walk statement chains.
(copy_tree_r): Handle 's' class nodes. Restore chains for
statements. Nullify scopes. Don't copy types.
(init_tree): Set lang_unsave to cp_unsave.
(remap_save_expr): Define.
* ir.texi: Document CTOR_STMT.
From-SVN: r30669
1999-11-25 21:32:04 +01:00
|
|
|
the cleanups associated with any SUBOBJECT_CLEANUPS need no longer
|
|
|
|
be run. */
|
|
|
|
DEFTREECODE (CTOR_STMT, "ctor_stmt", 'e', 0)
|
1999-09-12 03:12:59 +02:00
|
|
|
/* A CLEANUP_STMT marks the point at which a declaration is fully
|
|
|
|
constructed. If, after this point, the CLEANUP_DECL goes out of
|
|
|
|
scope, the CLEANUP_EXPR must be run. */
|
1999-09-18 01:14:49 +02:00
|
|
|
DEFTREECODE (CLEANUP_STMT, "cleanup_stmt", 'e', 2)
|
|
|
|
/* A START_CATCH_STMT marks the beginning of a catch handler for the
|
|
|
|
the START_CATCH_TYPE. If this is CATCH_ALL_TYPE, then the handler
|
|
|
|
catches all types. */
|
|
|
|
DEFTREECODE (START_CATCH_STMT, "start_catch_stmt", 'e', 0)
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (CTOR_INITIALIZER, "ctor_initializer", 'e', 2)
|
|
|
|
DEFTREECODE (RETURN_INIT, "return_init", 'e', 2)
|
1999-09-18 01:14:49 +02:00
|
|
|
DEFTREECODE (TRY_BLOCK, "try_block", 'e', 2)
|
|
|
|
DEFTREECODE (HANDLER, "handler", 'e', 2)
|
1997-12-12 07:49:29 +01:00
|
|
|
|
1998-04-24 00:26:41 +02:00
|
|
|
DEFTREECODE (TAG_DEFN, "tag_defn", 'e', 0)
|
|
|
|
|
|
|
|
/* And some codes for expressing conversions for overload resolution. */
|
|
|
|
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (IDENTITY_CONV, "identity_conv", 'e', 1)
|
|
|
|
DEFTREECODE (LVALUE_CONV, "lvalue_conv", 'e', 1)
|
|
|
|
DEFTREECODE (QUAL_CONV, "qual_conv", 'e', 1)
|
|
|
|
DEFTREECODE (STD_CONV, "std_conv", 'e', 1)
|
|
|
|
DEFTREECODE (PTR_CONV, "ptr_conv", 'e', 1)
|
|
|
|
DEFTREECODE (PMEM_CONV, "pmem_conv", 'e', 1)
|
|
|
|
DEFTREECODE (BASE_CONV, "base_conv", 'e', 1)
|
|
|
|
DEFTREECODE (REF_BIND, "ref_bind", 'e', 1)
|
1998-04-24 00:26:41 +02:00
|
|
|
DEFTREECODE (USER_CONV, "user_conv", 'e', 2)
|
1997-12-12 07:49:29 +01:00
|
|
|
DEFTREECODE (AMBIG_CONV, "ambig_conv", 'e', 1)
|
|
|
|
DEFTREECODE (RVALUE_CONV, "rvalue_conv", 'e', 1)
|
|
|
|
|
Support for friend templates.
* typeck.c (build_x_function_call): Handle static member function
templates like non-templates. Handle friend templates like normal
function templates.
* pt.c (tsubst, *_PARM): Don't use orig_level.
(get_bindings): Don't call add_to_template_args.
(instantiate_template): Likewise.
(tsubst, FUNCTION_DECL): Call add_to_template_args as appropriate.
* ptree.c (print_lang_type): Print index/level for template parms.
* Make-lang.in (cc1plus): Note that cc1plus depends on
cp/cp-tree.h and cp/cp-tree.def.
* cp-tree.def (TEMPLATE_CONST_PARM): Remove.
(TEMPLATE_PARM_INDEX): New tree code, used to indicate a
position in a template parameter list.
* cp-tree.h (template_parm_index): New structure, used as the tree
structure for a TEMPLATE_PARM_INDEX.
(TEMPLATE_PARM_IDX): New macro.
(TEMPLATE_PARM_LEVEL): Likewise.
(TEMPLATE_PARM_DESCENDANTS): Likewise.
(TEMPLATE_PARM_ORIG_LEVEL): Likewise.
(TEMPLATE_PARM_DECL): Likewise.
(TEMPLATE_TYPE_PARM_INDEX): Likewise.
(TEMPLATE_TYPE_ORIG_LEVEL): Likewise.
(TEMPLATE_TYPE_DECL): Likewise.
(TEMPLATE_CONST_IDX): Remove.
(TEMPLATE_CONST_LEVEL): Likewise.
(TEMPLATE_CONST_SET_INFO): Likewise.
(TEMPLATE_TYPE_SET_INFO): Likewise.
(TEMPLATE_TYPE_IDX): Redefine in terms of TEMPLATE_PARM_INDEX
node.
(TEMPLATE_TYPE_LEVEL): Likewise.
* decl.c (decls_match): Call comp_template_parms, rather than
expanding it inline.
(duplicate_decls): If two template declarations are being merged,
then their TEMPLATE_INFOs should be merged as well.
(grokfndecl): Save template-id information when declaring a friend
with explicit template arguments. Pass arguments to
check_explicit_specialization via correct convention; at some
point check_explicit_specialization changed, but these call-sites
did not.
(grokdeclarator): Tidy up slightly.
* decl2.c (check_classfn): Tidy up slightly. Don't assume that
two template functions with the same DECL_ASSEMBLER_NAME the same,
since the names are not yet mangled.
* error.c (dump_decl): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
(dump_expr): Likewise. Use the TEMPLATE_PARM_DECL to get at the
decl for a non-type parameter, rather than printing `<tparm ...>'.
* friend.c (is_friend): Handle TEMPLATE_DECL friends.
(do_friend): Deal with template friends.
* lex.c (do_pending_inlines): Call
maybe_begin_member_template_processing, rather than
conditionally calling begin_member_template_processing.
(process_next_inline): Likewise. Call
maybe_end_member_template_processing, rather than
conditionally calling end_member_template_processing.
(do_pending_defargs): Likewise.
(do_identifier): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
* method.c (build_mangled_template_parm_index): New function.
(build_overload_value): Use it.
(build_overload_name): Likewise.
* pt.c (finish_member_template_decl): Allow friend declarations.
(template_class_depth): New function.
(is_member_template): Rename, and modify, to become...
(is_member_or_friend_template): New function.
(end_member_template_processing): Rename, and modify, to become...
(maybe_end_member_template_processing).
(build_template_parm_index): New function.
(reduce_template_parm_level): New function.
(process_template_parm): Modify to use build_template_parm_index.
(current_template_args): Change name to current_template_parms.
(push_template_decl): Deal with friend templates.
(uses_template_parms): Use TEMPLATE_PARM_INDEX instead of
TEMPLATE_CONST_PARM.
(tsubst_friend_function): New function.
(instantiate_class_template): Generate the DECL_FRIENDLIST
for a new instantiation by using tsubst_friend_function rather
than just tsubst.
(tsubst): Don't tsubst into a type which is a TEMPLATE_DECL.
Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM, and the
appropriate new macros. Use reduce_template_parm_level to
generate lower-level template parameters. Handle tsubst'ing into
TEMPLATE_DECLS that declare TEMPLATE_TEMPLATE_PARMS. Don't forget
to tsubst the DECL_CONTEXT and DECL_CLASS_CONTEXT of newly created
templates. Similarly for the template parameters for a new
template.
(tsubst_copy): Tidy up slightly. Use TEMPLATE_PARM_INDEX instead
of TEMPLATE_CONST_PARM. Handle TYPE_DECLs by tsubsting into them.
(unify): Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM.
(get_bindings): Call add_to_template_args if necessary.
(instantiate_decl): Handle instantiations of friend templates.
* search.c (lookup_field_1): Don't treat the TYPE_FIELDS of a
TEMPLATE_TYPE_PARM as a list of fields; it's not!
* spew.c (yylex): Do a little manual constant propogation to
clarify the code.
From-SVN: r18198
1998-02-23 04:17:44 +01:00
|
|
|
/*
|
|
|
|
Local variables:
|
|
|
|
mode:c
|
|
|
|
End:
|
|
|
|
*/
|