pt.c (52750) | pt.c (60967) |
---|---|
1/* Handle parameterized types (templates) for GNU C++. 2 Copyright (C) 1992, 93-97, 1998, 1999 Free Software Foundation, Inc. 3 Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing. 4 Rewritten by Jason Merrill (jason@cygnus.com). 5 6This file is part of GNU CC. 7 8GNU CC is free software; you can redistribute it and/or modify --- 147 unchanged lines hidden (view full) --- 156 tree, tree, tree, int)); 157static tree get_template_base PROTO((tree, tree, tree, tree)); 158static tree try_class_unification PROTO((tree, tree, tree, tree)); 159static int coerce_template_template_parms PROTO((tree, tree, int, 160 tree, tree)); 161static tree determine_specialization PROTO((tree, tree, tree *, int)); 162static int template_args_equal PROTO((tree, tree)); 163static void print_template_context PROTO((int)); | 1/* Handle parameterized types (templates) for GNU C++. 2 Copyright (C) 1992, 93-97, 1998, 1999 Free Software Foundation, Inc. 3 Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing. 4 Rewritten by Jason Merrill (jason@cygnus.com). 5 6This file is part of GNU CC. 7 8GNU CC is free software; you can redistribute it and/or modify --- 147 unchanged lines hidden (view full) --- 156 tree, tree, tree, int)); 157static tree get_template_base PROTO((tree, tree, tree, tree)); 158static tree try_class_unification PROTO((tree, tree, tree, tree)); 159static int coerce_template_template_parms PROTO((tree, tree, int, 160 tree, tree)); 161static tree determine_specialization PROTO((tree, tree, tree *, int)); 162static int template_args_equal PROTO((tree, tree)); 163static void print_template_context PROTO((int)); |
164static int has_pvbases_p PROTO((tree, tree)); |
|
164 165/* We use TREE_VECs to hold template arguments. If there is only one 166 level of template arguments, then the TREE_VEC contains the 167 arguments directly. If there is more than one level of template 168 arguments, then each entry in the TREE_VEC is itself a TREE_VEC, 169 containing the template arguments for a single level. The first 170 entry in the outer TREE_VEC is the outermost level of template 171 parameters; the last is the innermost. --- 4508 unchanged lines hidden (view full) --- 4680 4681 /* Inject this template into the global scope. */ 4682 friend_type = TREE_TYPE (pushdecl_top_level (tmpl)); 4683 } 4684 4685 return friend_type; 4686} 4687 | 165 166/* We use TREE_VECs to hold template arguments. If there is only one 167 level of template arguments, then the TREE_VEC contains the 168 arguments directly. If there is more than one level of template 169 arguments, then each entry in the TREE_VEC is itself a TREE_VEC, 170 containing the template arguments for a single level. The first 171 entry in the outer TREE_VEC is the outermost level of template 172 parameters; the last is the innermost. --- 4508 unchanged lines hidden (view full) --- 4681 4682 /* Inject this template into the global scope. */ 4683 friend_type = TREE_TYPE (pushdecl_top_level (tmpl)); 4684 } 4685 4686 return friend_type; 4687} 4688 |
4689static int 4690has_pvbases_p (t, pattern) 4691 tree t, pattern; 4692{ 4693 if (!TYPE_USES_VIRTUAL_BASECLASSES (t)) 4694 return 0; 4695 4696 if (TYPE_USES_PVBASES (pattern)) 4697 return 1; 4698 4699 for (t = CLASSTYPE_VBASECLASSES (t); t; t = TREE_CHAIN (t)) 4700 if (TYPE_VIRTUAL_P (BINFO_TYPE (t))) 4701 return 1; 4702 4703 return 0; 4704} 4705 |
|
4688tree 4689instantiate_class_template (type) 4690 tree type; 4691{ 4692 tree template, args, pattern, t; 4693 tree typedecl; 4694 4695 if (type == error_mark_node) --- 334 unchanged lines hidden (view full) --- 5030 the field list by tsubst_enum above. */ 5031 if (!TREE_CHAIN (r)) 5032 { 5033 set_current_access_from_decl (r); 5034 finish_member_declaration (r); 5035 } 5036 } 5037 | 4706tree 4707instantiate_class_template (type) 4708 tree type; 4709{ 4710 tree template, args, pattern, t; 4711 tree typedecl; 4712 4713 if (type == error_mark_node) --- 334 unchanged lines hidden (view full) --- 5048 the field list by tsubst_enum above. */ 5049 if (!TREE_CHAIN (r)) 5050 { 5051 set_current_access_from_decl (r); 5052 finish_member_declaration (r); 5053 } 5054 } 5055 |
5056 /* After we have calculated the bases, we can now compute whether we 5057 have polymorphic vbases. This needs to happen before we 5058 instantiate the methods, because the constructors may take 5059 additional arguments. */ 5060 if (flag_vtable_thunks >= 2) 5061 TYPE_USES_PVBASES (type) = has_pvbases_p (type, pattern); 5062 |
|
5038 /* Set up the list (TYPE_METHODS) and vector (CLASSTYPE_METHOD_VEC) 5039 for this instantiation. */ 5040 for (t = TYPE_METHODS (pattern); t; t = TREE_CHAIN (t)) 5041 { 5042 tree r = tsubst (t, args, /*complain=*/1, NULL_TREE); 5043 set_current_access_from_decl (r); 5044 finish_member_declaration (r); 5045 } --- 665 unchanged lines hidden (view full) --- 5711 /* The ARGVEC was built on the momentary obstack. Make it 5712 permanent now. */ 5713 argvec = copy_to_permanent (argvec); 5714 DECL_TEMPLATE_INFO (r) 5715 = perm_tree_cons (gen_tmpl, argvec, NULL_TREE); 5716 SET_DECL_IMPLICIT_INSTANTIATION (r); 5717 register_specialization (r, gen_tmpl, argvec); 5718 | 5063 /* Set up the list (TYPE_METHODS) and vector (CLASSTYPE_METHOD_VEC) 5064 for this instantiation. */ 5065 for (t = TYPE_METHODS (pattern); t; t = TREE_CHAIN (t)) 5066 { 5067 tree r = tsubst (t, args, /*complain=*/1, NULL_TREE); 5068 set_current_access_from_decl (r); 5069 finish_member_declaration (r); 5070 } --- 665 unchanged lines hidden (view full) --- 5736 /* The ARGVEC was built on the momentary obstack. Make it 5737 permanent now. */ 5738 argvec = copy_to_permanent (argvec); 5739 DECL_TEMPLATE_INFO (r) 5740 = perm_tree_cons (gen_tmpl, argvec, NULL_TREE); 5741 SET_DECL_IMPLICIT_INSTANTIATION (r); 5742 register_specialization (r, gen_tmpl, argvec); 5743 |
5744 5745 if (DECL_CONSTRUCTOR_P (r) || DECL_DESTRUCTOR_P (r)) 5746 { 5747 maybe_retrofit_in_chrg (r); 5748 grok_ctor_properties (ctx, r); 5749 } 5750 |
|
5719 /* Set the mangled name for R. */ 5720 if (DECL_DESTRUCTOR_P (t)) | 5751 /* Set the mangled name for R. */ 5752 if (DECL_DESTRUCTOR_P (t)) |
5721 DECL_ASSEMBLER_NAME (r) = build_destructor_name (ctx); | 5753 DECL_ASSEMBLER_NAME (r) = 5754 build_destructor_name (ctx, DECL_DESTRUCTOR_FOR_PVBASE_P (r)); |
5722 else 5723 { 5724 /* Instantiations of template functions must be mangled 5725 specially, in order to conform to 14.5.5.1 5726 [temp.over.link]. */ 5727 tree tmpl = DECL_TI_TEMPLATE (t); 5728 5729 /* TMPL will be NULL if this is a specialization of a --- 26 unchanged lines hidden (view full) --- 5756 friends = &TREE_CHAIN (*friends)) 5757 { 5758 *friends = copy_node (*friends); 5759 TREE_VALUE (*friends) = tsubst (TREE_VALUE (*friends), 5760 args, /*complain=*/1, 5761 in_decl); 5762 } 5763 | 5755 else 5756 { 5757 /* Instantiations of template functions must be mangled 5758 specially, in order to conform to 14.5.5.1 5759 [temp.over.link]. */ 5760 tree tmpl = DECL_TI_TEMPLATE (t); 5761 5762 /* TMPL will be NULL if this is a specialization of a --- 26 unchanged lines hidden (view full) --- 5789 friends = &TREE_CHAIN (*friends)) 5790 { 5791 *friends = copy_node (*friends); 5792 TREE_VALUE (*friends) = tsubst (TREE_VALUE (*friends), 5793 args, /*complain=*/1, 5794 in_decl); 5795 } 5796 |
5797#if 0 5798 /* This has now moved further up. */ |
|
5764 if (DECL_CONSTRUCTOR_P (r)) 5765 { 5766 maybe_retrofit_in_chrg (r); 5767 grok_ctor_properties (ctx, r); 5768 } | 5799 if (DECL_CONSTRUCTOR_P (r)) 5800 { 5801 maybe_retrofit_in_chrg (r); 5802 grok_ctor_properties (ctx, r); 5803 } |
5804#endif |
|
5769 if (IDENTIFIER_OPNAME_P (DECL_NAME (r))) 5770 grok_op_properties (r, DECL_VIRTUAL_P (r), DECL_FRIEND_P (r)); 5771 } 5772 break; 5773 5774 case PARM_DECL: 5775 { 5776 r = copy_node (t); --- 4064 unchanged lines hidden --- | 5805 if (IDENTIFIER_OPNAME_P (DECL_NAME (r))) 5806 grok_op_properties (r, DECL_VIRTUAL_P (r), DECL_FRIEND_P (r)); 5807 } 5808 break; 5809 5810 case PARM_DECL: 5811 { 5812 r = copy_node (t); --- 4064 unchanged lines hidden --- |