90th Cygnus<->FSF quick merge
authorMike Stump <mrs@gcc.gnu.org>
Wed, 12 Feb 1997 20:23:55 +0000 (20:23 +0000)
committerMike Stump <mrs@gcc.gnu.org>
Wed, 12 Feb 1997 20:23:55 +0000 (20:23 +0000)
From-SVN: r13629

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/gxxint.texi
gcc/cp/lang-options.h
gcc/cp/new1.cc
gcc/cp/pt.c
gcc/cp/rtti.c

index a6d564f..8f1f715 100644 (file)
@@ -1,3 +1,28 @@
+Tue Feb 11 13:50:48 1997  Mike Stump  <mrs@cygnus.com>
+
+       * 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 <bruno@linuix.mathematik.uni-karlsruhe.de>
+
+       * 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  <jason@yorick.cygnus.com>
+
+       * 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  <jason@yorick.cygnus.com>
 
        * pt.c (unify, case TEMPLATE_CONST_PARM): Use cp_tree_equal.
index 3c41f22..2660110 100644 (file)
@@ -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;
index 5700689..fe4228d 100644 (file)
@@ -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:
index dbfc234..2c91fbf 100644 (file)
@@ -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;
index 1869aef..ed76bcf 100644 (file)
@@ -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",
index a0377e1..0ee111d 100644 (file)
@@ -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);
index 7e8c184..89002d4 100644 (file)
@@ -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)
index 4a2bcbb..0fbfc01 100644 (file)
@@ -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));