Hello,

this patch fixes the layout of the info_type-s for llp64 target.  We
used here 'long' type instead
of pointer-scalar-witdth type.  That's an issue for llp64 targets.
I introduced for that the LONGPTR_T helper-macro, which has either
scalar-size of 'long' type, or
of 'long long' type's size, if pointer is larger then scalar-size of
'long' type.

ChangeLog

2012-12-21  Kai Tietz

        * rtti.c (LONGPTR_T): New helper-macro.
        (get_pseudo_ti_init): Initialize offset_type by LONGPTR_T
        type instead of 'long' type.
        (create_tinfo_types): Use for offset/flags field LONGPTR_T
        type instead of 'long' type.

Tested for x86_64-w64-mingw32, i686-w64-mingw32, and
x86_64-unknown-linux-gnu.  Ok for apply?

Regards,
Kai

Index: rtti.c
===================================================================
--- rtti.c      (Revision 194660)
+++ rtti.c      (Arbeitskopie)
@@ -89,6 +89,12 @@ typedef enum tinfo_kind
   /* ...                  abi::__vmi_type_info<I> */
 } tinfo_kind;

+/* Helper macro to get maximum scalar-width of pointer or of the 'long'-type.
+   This of interest for llp64 targets.  */
+#define LONGPTR_T \
+  integer_types[(POINTER_SIZE <= TYPE_PRECISION (integer_types[itk_long]) \
+                ? itk_long : itk_long_long)]
+
 /* A vector of all tinfo decls that haven't yet been emitted.  */
 vec<tree, va_gc> *unemitted_tinfo_decls;

@@ -1116,7 +1122,7 @@ get_pseudo_ti_init (tree type, unsigned tk_index)
        tree binfo = TYPE_BINFO (type);
        int nbases = BINFO_N_BASE_BINFOS (binfo);
        vec<tree, va_gc> *base_accesses = BINFO_BASE_ACCESSES (binfo);
-       tree offset_type = integer_types[itk_long];
+       tree offset_type = LONGPTR_T;
        tree base_inits = NULL_TREE;
        int ix;
        vec<constructor_elt, va_gc> *init_vec = NULL;
@@ -1413,14 +1419,15 @@ create_tinfo_types (void)
   /* Base class internal helper. Pointer to base type, offset to base,
      flags.  */
   {
-    tree field, fields;
+    tree field, fields, offset_flags_type;

     field = build_decl (BUILTINS_LOCATION,
                        FIELD_DECL, NULL_TREE, type_info_ptr_type);
     fields = field;

+    offset_flags_type = LONGPTR_T;
     field = build_decl (BUILTINS_LOCATION,
-                       FIELD_DECL, NULL_TREE, integer_types[itk_long]);
+                       FIELD_DECL, NULL_TREE, offset_flags_type);
     DECL_CHAIN (field) = fields;
     fields = field;

Reply via email to