]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/cp/rtti.c
* rtti.c (synthesize_tinfo_fn): Set DECL_DEFER_OUTPUT.
[gcc.git] / gcc / cp / rtti.c
index 5ab8d63f85bd70850c19d0c5445462bbf4c32d37..87d6df11ef645514c04879af3432609515f20047 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);
 
@@ -588,6 +585,7 @@ build_dynamic_cast_1 (type, expr)
        {
          tree retval;
           tree result, td1, td2, td3, elems, expr2;
+          tree static_type, target_type, boff;
 
          /* If we got here, we can't convert statically.  Therefore,
             dynamic_cast<D&>(b) (b an object) cannot succeed.  */
@@ -632,20 +630,23 @@ build_dynamic_cast_1 (type, expr)
            td1 = get_tinfo_fn_dynamic (expr);
          td1 = decay_conversion (td1);
          
-         td2 = decay_conversion
-           (get_tinfo_fn (TYPE_MAIN_VARIANT (TREE_TYPE (type))));
-         td3 = decay_conversion
-           (get_tinfo_fn (TYPE_MAIN_VARIANT (TREE_TYPE (exprtype))));
+         target_type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
+         static_type = TYPE_MAIN_VARIANT (TREE_TYPE (exprtype));
+         td2 = decay_conversion (get_tinfo_fn (target_type));
+         td3 = decay_conversion (get_tinfo_fn (static_type));
+
+          /* Determine how T and V are related.  */
+          boff = get_dynamic_cast_base_type (static_type, target_type);
 
           elems = tree_cons
            (NULL_TREE, td1, tree_cons
             (NULL_TREE, td2, tree_cons
-             (NULL_TREE, build_int_2 (1, 0), tree_cons
+             (NULL_TREE, boff, tree_cons
               (NULL_TREE, expr2, tree_cons
-               (NULL_TREE, td3, tree_cons
+               (NULL_TREE, td3, tree_cons
                 (NULL_TREE, expr1, NULL_TREE))))));
 
-         dcast_fn = get_identifier ("__dynamic_cast");
+         dcast_fn = get_identifier ("__dynamic_cast_2");
          if (IDENTIFIER_GLOBAL_VALUE (dcast_fn))
            dcast_fn = IDENTIFIER_GLOBAL_VALUE (dcast_fn);
          else
@@ -656,7 +657,7 @@ build_dynamic_cast_1 (type, expr)
              tmp = tree_cons
                (NULL_TREE, TREE_TYPE (td1), tree_cons
                 (NULL_TREE, TREE_TYPE (td1), tree_cons
-                 (NULL_TREE, integer_type_node, tree_cons
+                 (NULL_TREE, integer_type_node, tree_cons
                   (NULL_TREE, ptr_type_node, tree_cons
                    (NULL_TREE, TREE_TYPE (td1), tree_cons
                     (NULL_TREE, ptr_type_node, void_list_node))))));
@@ -691,6 +692,9 @@ build_dynamic_cast_1 (type, expr)
        }
     }
 
+  cp_error ("dynamic_cast from non-polymorphic type `%#T'", exprtype);
+  return error_mark_node;
+
  fail:
   cp_error ("cannot dynamic_cast `%E' (of type `%#T') to type `%#T'",
            expr, exprtype, type);
@@ -1129,6 +1133,7 @@ synthesize_tinfo_fn (fndecl)
   /* Begin processing the function.  */
   start_function (NULL_TREE, fndecl, NULL_TREE, 
                  SF_DEFAULT | SF_PRE_PARSED);
+  DECL_DEFER_OUTPUT (fndecl) = 1;
   store_parm_decls ();
   clear_last_expr ();
 
@@ -1136,11 +1141,8 @@ synthesize_tinfo_fn (fndecl)
   compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
 
   /* For convenience, we save away the address of the static
-     variable.  Since we will process expression-statements between
-     here and the end of the function, we must call push_momentary to
-     keep ADDR from being overwritten.  */
+     variable.  */
   addr = decay_conversion (tdecl);
-  push_momentary ();
 
   /* If the first word of the array (the vtable) is non-zero, we've already
      initialized the object, so don't do it again.  */
@@ -1192,8 +1194,6 @@ synthesize_tinfo_fn (fndecl)
   tmp = cp_convert (build_pointer_type (type_info_type_node), addr);
   tmp = build_indirect_ref (tmp, 0);
   finish_return_stmt (tmp);
-  /* Undo the call to push_momentary above.  */
-  pop_momentary ();
   /* Finish the function body.  */
   finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
   expand_body (finish_function (lineno, 0));
This page took 0.030201 seconds and 5 git commands to generate.