From e9f32eb5034600b035f2d40e1723432cff8b74ba Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Wed, 12 Feb 1997 20:23:55 +0000 Subject: [PATCH] 90th Cygnus<->FSF quick merge From-SVN: r13629 --- gcc/cp/ChangeLog | 25 +++++++++++++++ gcc/cp/decl.c | 5 ++- gcc/cp/decl2.c | 23 ++++++++++++++ gcc/cp/gxxint.texi | 73 +++---------------------------------------- gcc/cp/lang-options.h | 1 + gcc/cp/new1.cc | 2 ++ gcc/cp/pt.c | 3 +- gcc/cp/rtti.c | 13 +++++--- 8 files changed, 68 insertions(+), 77 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a6d564fc7e3..8f1f7152e6c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,28 @@ +Tue Feb 11 13:50:48 1997 Mike Stump + + * new1.cc: Include a declaration for malloc, to avoid warning, and + avoid lossing on systems that require one (ones that define malloc + in xm.h). + +Mon Feb 10 22:51:13 1997 Bruno Haible + + * decl2.c (max_tinst_depth): New variable. + (lang_decode_option): Parse "-ftemplate-depth-NN" command line + option. + * pt.c (max_tinst_depth): Variable moved. + * lang-options.h: Declare "-ftemplate-depth-NN" command line option + as legal. + +Fri Feb 7 15:43:34 1997 Jason Merrill + + * decl.c (xref_basetypes): Allow a base class that depends on + template parms to be incomplete. + + * decl2.c (build_expr_from_tree): Support typeid(type). + * rtti.c (get_typeid): Support templates. + (expand_si_desc, expand_class_desc): Fix string length. + (expand_ptr_desc, expand_attr_desc, expand_generic_desc): Likewise. + Tue Feb 4 11:28:24 1997 Jason Merrill * pt.c (unify, case TEMPLATE_CONST_PARM): Use cp_tree_equal. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3c41f225e75..26601104b9a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10492,9 +10492,8 @@ xref_basetypes (code_type_node, name, ref, binfo) } #if 1 /* This code replaces similar code in layout_basetypes. */ - else if (TREE_CODE (basetype) != TEMPLATE_TYPE_PARM - && TREE_CODE (basetype) != TYPENAME_TYPE - && TYPE_SIZE (complete_type (basetype)) == NULL_TREE) + else if (TYPE_SIZE (complete_type (basetype)) == NULL_TREE + && ! (current_template_parms && uses_template_parms (basetype))) { cp_error ("base class `%T' has incomplete type", basetype); continue; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 570068981bd..fe4228d5ee6 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -376,6 +376,11 @@ int flag_new_for_scope = 1; int flag_weak = 1; +/* Maximum template instantiation depth. Must be at least 17 for ANSI + compliance. */ + +int max_tinst_depth = 17; + /* Table of language-dependent -f options. STRING is the option name. VARIABLE is the address of the variable. ON_VALUE is the value to store in VARIABLE @@ -492,6 +497,22 @@ lang_decode_option (p) flag_implicit_templates = 0; found = 1; } + else if (!strncmp (p, "template-depth-", 15)) + { + char *endp = p + 15; + while (*endp) + { + if (*endp >= '0' && *endp <= '9') + endp++; + else + { + error ("Invalid option `%s'", p - 2); + goto template_depth_lose; + } + } + max_tinst_depth = atoi (p + 15); + template_depth_lose: ; + } else for (j = 0; !found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]); j++) @@ -3442,6 +3463,8 @@ build_expr_from_tree (t) } case TYPEID_EXPR: + if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (t, 0))) == 't') + return get_typeid (TREE_OPERAND (t, 0)); return build_x_typeid (build_expr_from_tree (TREE_OPERAND (t, 0))); case VAR_DECL: diff --git a/gcc/cp/gxxint.texi b/gcc/cp/gxxint.texi index dbfc2346883..2c91fbfc98d 100644 --- a/gcc/cp/gxxint.texi +++ b/gcc/cp/gxxint.texi @@ -53,38 +53,6 @@ Access checking is unimplemented for nested types. @item @code{volatile} is not implemented in general. -@cindex pointers to members -@item -Pointers to members are only minimally supported, and there are places -where the grammar doesn't even properly accept them yet. - -@cindex multiple inheritance -@item -@code{this} will be wrong in virtual members functions defined in a -virtual base class, when they are overridden in a derived class, when -called via a non-left most object. - -An example would be: - -@example -extern "C" int printf(const char*, ...); -struct A @{ virtual void f() @{ @} @}; -struct B : virtual A @{ int b; B() : b(0) @{@} void f() @{ b++; @} @}; -struct C : B @{@}; -struct D : B @{@}; -struct E : C, D @{@}; -int main() -@{ - E e; - C& c = e; D& d = e; - c.f(); d.f(); - printf ("C::b = %d, D::b = %d\n", e.C::b, e.D::b); - return 0; -@} -@end example - -This will print out 2, 0, instead of 1,1. - @end itemize @node Routines, Implementation Specifics, Limitations of g++, Top @@ -1507,21 +1475,6 @@ between a cleanup-rethrower, and a real handler, if would also have to have a way to know if a handler `matches' a thrown exception, and this is frontend specific. -The UNSAVE_EXPR tree code has to be migrated to the backend. Exprs such -as TARGET_EXPRs, WITH_CLEANUP_EXPRs, CALL_EXPRs and RTL_EXPRs have to be -changed to support unsaving. This is meant to be a complete list. -SAVE_EXPRs can be unsaved already. expand_decl_cleanup should be -changed to unsave it's argument, if needed. See -cp/tree.c:cp_expand_decl_cleanup, unsave_expr_now, unsave_expr, and -cp/expr.c:cplus_expand_expr(case UNSAVE_EXPR:) for the UNSAVE_EXPR code. -Now, as to why... because kenner already tripped over the exact same -problem in Ada, we talked about it, he didn't like any of the solution, -but yet, didn't like no solution either. He was willing to live with -the drawbacks of this solution. The drawback is unsave_expr_now. It -should have a callback into the frontend, to allow the unsaveing of -frontend special codes. The callback goes in, inplace of the call to -my_friendly_abort. - The stack unwinder is one of the hardest parts to do. It is highly machine dependent. The form that kenner seems to like was a couple of macros, that would do the machine dependent grunt work. One preexisting @@ -1530,31 +1483,15 @@ macro he seemed to want was __builtin_return_address, and the other would do the hard work of fixing up the registers, adjusting the stack pointer, frame pointer, arg pointer and so on. -The eh archive (~mrs/eh) might be good reading for understanding the Ada -perspective, and some of kenners mindset, and a detailed explanation -(Message-Id: <9308301130.AA10543@@vlsi1.ultra.nyu.edu>) of the concepts -involved. - -Here is a guide to existing backend type code. It is all in -cp/except.c. Check out do_unwind, and expand_builtin_throw for current -code on how to figure out what handler matches an exception, -emit_exception_table for code on emitting the PC range table that is -built during compilation, expand_exception_blocks for code that emits -all the handlers at the end of a functions, end_protect to mark the end -of an exception region, start_protect to mark the start of an exception -region, lang_interim_eh is the master hook used by the backend into the -EH backend that now exists in the frontend, and expand_internal_throw to -raise an exception. - @node Free Store, Concept Index, Exception Handling, Top @section Free Store -operator new [] adds a magic cookie to the beginning of arrays for which -the number of elements will be needed by operator delete []. These are -arrays of objects with destructors and arrays of objects that define -operator delete [] with the optional size_t argument. This cookie can -be examined from a program as follows: +@code{operator new []} adds a magic cookie to the beginning of arrays +for which the number of elements will be needed by @code{operator delete +[]}. These are arrays of objects with destructors and arrays of objects +that define @code{operator delete []} with the optional size_t argument. +This cookie can be examined from a program as follows: @example typedef unsigned long size_t; diff --git a/gcc/cp/lang-options.h b/gcc/cp/lang-options.h index 1869aef0dbd..ed76bcf349f 100644 --- a/gcc/cp/lang-options.h +++ b/gcc/cp/lang-options.h @@ -76,6 +76,7 @@ Boston, MA 02111-1307, USA. */ "-fno-stats", "-fstrict-prototype", "-fno-strict-prototype", + "-ftemplate-depth-", "-fthis-is-variable", "-fno-this-is-variable", "-fvtable-thunks", diff --git a/gcc/cp/new1.cc b/gcc/cp/new1.cc index a0377e1c575..0ee111d2939 100644 --- a/gcc/cp/new1.cc +++ b/gcc/cp/new1.cc @@ -27,6 +27,8 @@ #include "new" +extern "C" void *malloc (size_t); + typedef void (*vfp)(void); extern vfp __new_handler; extern void __default_new_handler (void); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7e8c18475db..89002d47aac 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -963,7 +963,7 @@ uses_template_parms (t) static struct tinst_level *current_tinst_level = 0; static struct tinst_level *free_tinst_level = 0; static int tinst_depth = 0; -int max_tinst_depth = 17; +extern int max_tinst_depth; #ifdef GATHER_STATISTICS int depth_reached = 0; #endif @@ -982,6 +982,7 @@ push_tinst_level (d) error ("template instantiation depth exceeds maximum of %d", max_tinst_depth); + error (" (use -ftemplate-depth-NN to increase the maximum)"); cp_error (" instantiating `%D'", d); for (; p; p = p->next) diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 4a2bcbbe7fb..0fbfc01eff9 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -373,6 +373,9 @@ get_typeid (type) if (type == error_mark_node) return error_mark_node; + if (processing_template_decl) + return build_min_nt (TYPEID_EXPR, type); + /* If the type of the type-id is a reference type, the result of the typeid expression refers to a type_info object representing the referenced type. */ @@ -652,7 +655,7 @@ expand_si_desc (tdecl, type) { tree t, elems, fn; char *name = build_overload_name (type, 1, 1); - tree name_string = combine_strings (build_string (strlen (name), name)); + tree name_string = combine_strings (build_string (strlen (name)+1, name)); type = BINFO_TYPE (TREE_VEC_ELT (TYPE_BINFO_BASETYPES (type), 0)); expand_expr_stmt (get_typeid_1 (type)); @@ -825,7 +828,7 @@ expand_class_desc (tdecl, type) #endif name = build_overload_name (type, 1, 1); - name_string = combine_strings (build_string (strlen (name), name)); + name_string = combine_strings (build_string (strlen (name)+1, name)); { tree arrtype = build_array_type (base_info_type_node, NULL_TREE); @@ -877,7 +880,7 @@ expand_ptr_desc (tdecl, type) { tree t, elems, fn; char *name = build_overload_name (type, 1, 1); - tree name_string = combine_strings (build_string (strlen (name), name)); + tree name_string = combine_strings (build_string (strlen (name)+1, name)); type = TREE_TYPE (type); expand_expr_stmt (get_typeid_1 (type)); @@ -924,7 +927,7 @@ expand_attr_desc (tdecl, type) { tree elems, t, fn; char *name = build_overload_name (type, 1, 1); - tree name_string = combine_strings (build_string (strlen (name), name)); + tree name_string = combine_strings (build_string (strlen (name)+1, name)); tree attrval = build_int_2 (TYPE_READONLY (type) | TYPE_VOLATILE (type) * 2, 0); @@ -973,7 +976,7 @@ expand_generic_desc (tdecl, type, fnname) char *fnname; { char *name = build_overload_name (type, 1, 1); - tree name_string = combine_strings (build_string (strlen (name), name)); + tree name_string = combine_strings (build_string (strlen (name)+1, name)); tree elems = tree_cons (NULL_TREE, decay_conversion (tdecl), tree_cons (NULL_TREE, decay_conversion (name_string), NULL_TREE)); -- 2.30.2