objc-act.c (build_constructor): Cast initializer values to the proper field types.
authorRichard Henderson <rth@redhat.com>
Tue, 11 Dec 2001 18:07:01 +0000 (10:07 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Tue, 11 Dec 2001 18:07:01 +0000 (10:07 -0800)
        * objc/objc-act.c (build_constructor): Cast initializer values
        to the proper field types.

From-SVN: r47884

gcc/ChangeLog
gcc/objc/objc-act.c

index 4fe21250d76e0d34124044e4a803e9af8f39f31a..b5c02519b09d6830b2f5bba95d17880e28d8b591 100644 (file)
@@ -1,3 +1,8 @@
+2001-12-11  Richard Henderson  <rth@redhat.com>
+
+       * objc/objc-act.c (build_constructor): Cast initializer values
+       to the proper field types.
+
 2001-12-11  Jakub Jelinek  <jakub@redhat.com>
 
        * unwind-dw2.c (execute_cfa_program): Fix DW_CFA_restore handling.
index a04f631e405caeca3fb48d4f07cf219d1b717890..bf770e9cb8958277d9e6f7a6457c262779e95f7c 100644 (file)
@@ -1371,8 +1371,27 @@ static tree
 build_constructor (type, elts)
      tree type, elts;
 {
-  tree constructor = build (CONSTRUCTOR, type, NULL_TREE, elts);
+  tree constructor, f, e;
 
+  /* ??? Most of the places that we build constructors, we don't fill in
+     the type of integers properly.  Convert them all en masse.  */
+  if (TREE_CODE (type) == ARRAY_TYPE)
+    {
+      f = TREE_TYPE (type);
+      if (TREE_CODE (f) == POINTER_TYPE || TREE_CODE (f) == INTEGER_TYPE)
+       for (e = elts; e ; e = TREE_CHAIN (e))
+         TREE_VALUE (e) = convert (f, TREE_VALUE (e));
+    }
+  else
+    {
+      f = TYPE_FIELDS (type);
+      for (e = elts; e ; e = TREE_CHAIN (e), f = TREE_CHAIN (f))
+       if (TREE_CODE (TREE_TYPE (f)) == POINTER_TYPE
+           || TREE_CODE (TREE_TYPE (f)) == INTEGER_TYPE)
+         TREE_VALUE (e) = convert (TREE_TYPE (f), TREE_VALUE (e));
+    }
+
+  constructor = build (CONSTRUCTOR, type, NULL_TREE, elts);
   TREE_CONSTANT (constructor) = 1;
   TREE_STATIC (constructor) = 1;
   TREE_READONLY (constructor) = 1;