]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Support normal type_info-based EH mechanisms with -fno-rtti.
authorJason Merrill <jason@yorick.cygnus.com>
Thu, 30 Sep 1999 00:50:29 +0000 (00:50 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 30 Sep 1999 00:50:29 +0000 (20:50 -0400)
* except.c (build_eh_type_type): Remove special -fno-rtti handling.
(build_eh_type_type_ref): Likewise.
(build_eh_type): Remove.
(expand_throw): Call build_eh_type_type, not build_eh_type.
* decl2.c (import_export_decl): Don't associate the tinfo fn with
the vtable if -fno-rtti.
* decl.c (init_decl_processing): Always init_rtti_processing.

* rtti.c (get_typeid): Don't complain about -fno-rtti.

From-SVN: r29715

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/except.c
gcc/cp/rtti.c

index 905047b6c5e72e3b05b9262979c593a6a64bce73..43ebd72f99b30f74fa6f4bc57cc9d65e3af83752 100644 (file)
@@ -1,5 +1,16 @@
 1999-09-29  Jason Merrill  <jason@yorick.cygnus.com>
 
+       Support normal type_info-based EH mechanisms with -fno-rtti.
+       * except.c (build_eh_type_type): Remove special -fno-rtti handling.
+       (build_eh_type_type_ref): Likewise.
+       (build_eh_type): Remove.
+       (expand_throw): Call build_eh_type_type, not build_eh_type.
+       * decl2.c (import_export_decl): Don't associate the tinfo fn with
+       the vtable if -fno-rtti.
+       * decl.c (init_decl_processing): Always init_rtti_processing.
+
+       * rtti.c (get_typeid): Don't complain about -fno-rtti.
+
        * class.c (class_cache_obstack, class_obstack): Remove.
        (init_class_processing): Don't initialize class_obstack.
        (push_cache_obstack): Remove.
index 9ff542ef0fc5fa266f0cdf3b1173f099a5ae6b69..bdbd1e8c8b1fb3941076b40e91e7a3e74eb7df35 100644 (file)
@@ -6330,8 +6330,7 @@ init_decl_processing ()
   init_class_processing ();
   init_init_processing ();
   init_search_processing ();
-  if (flag_rtti)
-    init_rtti_processing ();
+  init_rtti_processing ();
 
   if (flag_exceptions)
     init_exception_processing ();
index 19868c300e5350baa80c745ba3610f53d3299d51..6fb90fe64414af0813194f8ce3dc5924744288fa 100644 (file)
@@ -2685,6 +2685,10 @@ import_export_decl (decl)
 
       if (IS_AGGR_TYPE (ctype) && CLASSTYPE_INTERFACE_KNOWN (ctype)
          && TYPE_VIRTUAL_P (ctype)
+         /* If -fno-rtti, we're not necessarily emitting this stuff with
+            the class, so go ahead and emit it now.  This can happen
+            when a class is used in exception handling.  */
+         && flag_rtti
          /* If the type is a cv-qualified variant of a type, then we
             must emit the tinfo function in this translation unit
             since it will not be emitted when the vtable for the type
index eec0d7c5e167a3f63b7fbd02362ec3af52495c31..72644e63847d319ac6efab62274ab7ea50e96d52 100644 (file)
@@ -38,7 +38,6 @@ Boston, MA 02111-1307, USA.  */
 
 static void push_eh_cleanup PROTO((void));
 static tree build_eh_type_type PROTO((tree));
-static tree build_eh_type PROTO((tree));
 static tree call_eh_info PROTO((void));
 static void push_eh_info PROTO((void));
 static tree get_eh_info PROTO((void));
@@ -333,9 +332,6 @@ static tree
 build_eh_type_type (type)
      tree type;
 {
-  const char *typestring;
-  tree exp;
-
   if (type == error_mark_node)
     return error_mark_node;
 
@@ -346,22 +342,16 @@ build_eh_type_type (type)
   /* Peel off cv qualifiers.  */
   type = TYPE_MAIN_VARIANT (type);
 
-  if (flag_rtti)
-    return build1 (ADDR_EXPR, ptr_type_node, get_typeid_1 (type));
-
-  typestring = build_overload_name (type, 1, 1);
-  exp = combine_strings (build_string (strlen (typestring)+1, typestring));
-  return build1 (ADDR_EXPR, ptr_type_node, exp);
+  return build1 (ADDR_EXPR, ptr_type_node, get_typeid_1 (type));
 }
 
-/* Build the address of a runtime type for use in the runtime matching
-   field of the new exception model */
+/* Build the address of a typeinfo function for use in the runtime
+   matching field of the new exception model */
 
 static tree
 build_eh_type_type_ref (type)
      tree type;
 {
-  const char *typestring;
   tree exp;
 
   if (type == error_mark_node)
@@ -374,41 +364,12 @@ build_eh_type_type_ref (type)
   /* Peel off cv qualifiers.  */
   type = TYPE_MAIN_VARIANT (type);
 
-  push_permanent_obstack ();
+  exp = get_tinfo_fn (type);
+  exp = build1 (ADDR_EXPR, ptr_type_node, exp);
 
-  if (flag_rtti)
-    {
-      exp = get_tinfo_fn (type);
-      TREE_USED (exp) = 1;
-      mark_inline_for_output (exp);
-      exp = build1 (ADDR_EXPR, ptr_type_node, exp);
-    }
-  else
-    {
-      typestring = build_overload_name (type, 1, 1);
-      exp = combine_strings (build_string (strlen (typestring)+1, typestring));
-      exp = build1 (ADDR_EXPR, ptr_type_node, exp);
-    }
-  pop_obstacks ();
   return (exp);
 }
 
-
-/* Build a type value for use at runtime for a exp that is thrown or
-   matched against by the exception handling system.  */
-
-static tree
-build_eh_type (exp)
-     tree exp;
-{
-  if (flag_rtti)
-    {
-      exp = build_typeid (exp);
-      return build1 (ADDR_EXPR, ptr_type_node, exp);
-    }
-  return build_eh_type_type (TREE_TYPE (exp));
-}
-
 /* This routine is called to mark all the symbols representing runtime
    type functions in the exception table as haveing been referenced.
    This will make sure code is emitted for them. Called from finish_file. */
@@ -859,7 +820,7 @@ expand_throw (exp)
             (NULL_TREE, integer_type_node, void_list_node))));
 
       if (TYPE_PTR_P (TREE_TYPE (exp)))
-       throw_type = build_eh_type (exp);
+       throw_type = build_eh_type_type (TREE_TYPE (exp));
       else
        {
          tree object, ptr;
@@ -907,7 +868,7 @@ expand_throw (exp)
          finish_cleanup_try_block (try_block);
          finish_cleanup (build_terminate_handler (), try_block);
 
-         throw_type = build_eh_type (object);
+         throw_type = build_eh_type_type (TREE_TYPE (object));
 
          if (TYPE_HAS_DESTRUCTOR (TREE_TYPE (object)))
            {
index 8ce5102e6fc0204f76224fd2945f660b8c23d71f..f5eb8935ad1e65e3893598bc29f73c5768954c3a 100644 (file)
@@ -424,9 +424,6 @@ get_typeid (type)
       return error_mark_node;
     }
   
-  if (! flag_rtti)
-    error ("requesting typeid with -fno-rtti");
-
   if (processing_template_decl)
     return build_min_nt (TYPEID_EXPR, type);