OSDN Git Service

PR c++/50089
[pf3gnuchains/gcc-fork.git] / gcc / cp / rtti.c
index d7a151d..434b772 100644 (file)
@@ -1,6 +1,6 @@
 /* RunTime Type Identification
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008, 2009
+   2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Mostly written by Jason Merrill (jason@cygnus.com).
 
@@ -29,8 +29,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "cp-tree.h"
 #include "flags.h"
 #include "output.h"
-#include "assert.h"
-#include "toplev.h"
 #include "convert.h"
 #include "target.h"
 #include "c-family/c-pragma.h"
@@ -194,8 +192,7 @@ build_headof (tree exp)
 
   type = cp_build_qualified_type (ptr_type_node,
                                  cp_type_quals (TREE_TYPE (exp)));
-  return build2 (POINTER_PLUS_EXPR, type, exp,
-                convert_to_integer (sizetype, offset));
+  return fold_build_pointer_plus (exp, offset);
 }
 
 /* Get a bad_cast node for the program to throw...
@@ -328,6 +325,8 @@ build_typeid (tree exp)
   if (processing_template_decl)
     return build_min (TYPEID_EXPR, const_type_info_type_node, exp);
 
+  /* FIXME when integrating with c_fully_fold, mark
+     resolves_to_fixed_type_p case as a non-constant expression.  */
   if (TREE_CODE (exp) == INDIRECT_REF
       && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == POINTER_TYPE
       && TYPE_POLYMORPHIC_P (TREE_TYPE (exp))
@@ -406,6 +405,8 @@ get_tinfo_decl (tree type)
     type = build_function_type (TREE_TYPE (type),
                                TREE_CHAIN (TYPE_ARG_TYPES (type)));
 
+  type = complete_type (type);
+
   /* For a class type, the variable is cached in the type node
      itself.  */
   if (CLASS_TYPE_P (type))
@@ -916,8 +917,8 @@ tinfo_base_init (tinfo_s *ti, tree target)
       vtable_ptr = cp_build_addr_expr (vtable_ptr, tf_warning_or_error);
 
       /* We need to point into the middle of the vtable.  */
-      vtable_ptr = build2
-       (POINTER_PLUS_EXPR, TREE_TYPE (vtable_ptr), vtable_ptr,
+      vtable_ptr = fold_build_pointer_plus
+       (vtable_ptr,
         size_binop (MULT_EXPR,
                     size_int (2 * TARGET_VTABLE_DATA_ENTRY_DISTANCE),
                     TYPE_SIZE_UNIT (vtable_entry_type)));
@@ -1051,12 +1052,11 @@ typeinfo_in_lib_p (tree type)
     case BOOLEAN_TYPE:
     case REAL_TYPE:
     case VOID_TYPE:
+    case NULLPTR_TYPE:
       return true;
 
     case LANG_TYPE:
-      if (NULLPTR_TYPE_P (type))
-       return true;
-      /* else fall through.  */
+      /* fall through.  */
 
     default:
       return false;