]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* lto-symtab.c (warn_type_compatibility_p): Do not set ODR mismatch
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 21 Nov 2015 22:30:28 +0000 (22:30 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 21 Nov 2015 22:30:28 +0000 (22:30 +0000)
flag for types that are not ODR; fix loop walking parameters.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230712 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/lto/ChangeLog
gcc/lto/lto-symtab.c

index c97c85db40287d417b4c9835f01d3e07b0b7b221..49adea611046ec18568f649431ae220683ad59d6 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-11  Jan Hubicka  <hubicka@ucw.cz>
+
+       * lto-symtab.c (warn_type_compatibility_p): Do not set ODR mismatch
+       flag for types that are not ODR; fix loop walking parameters.
+
 2015-11-11  Andrew MacLeod  <amacleod@redhat.com>
 
        * lto-lang.c: Remove unused header files.
index 7f12760c08d67f2065ade29db60cae76976bb8bc..cef7ad383c65479c2d16ece3ac98f71e1e34a01c 100644 (file)
@@ -180,16 +180,26 @@ lto_varpool_replace_node (varpool_node *vnode,
 /* Return non-zero if we want to output waring about T1 and T2.
    Return value is a bitmask of reasons of violation:
    Bit 0 indicates that types are not compatible of memory layout.
-   Bot 1 indicates that types are not compatible because of C++ ODR rule.  */
+   Bit 1 indicates that types are not compatible because of C++ ODR rule.  */
 
 static int
 warn_type_compatibility_p (tree prevailing_type, tree type)
 {
   int lev = 0;
+
+  /* Get complete type.
+     ???  We might want to emit a warning here if type qualification
+     differences were spotted.  Do not do this unconditionally though.  */
+  type = TYPE_MAIN_VARIANT (type);
+  prevailing_type = TYPE_MAIN_VARIANT (prevailing_type);
+  if (prevailing_type == type)
+    return 0;
+
+  bool odr_p = odr_or_derived_type_p (prevailing_type)
+              && odr_or_derived_type_p (type);
   /* C++ provide a robust way to check for type compatibility via the ODR
      rule.  */
-  if (odr_or_derived_type_p (prevailing_type) && odr_or_derived_type_p (type)
-      && !odr_types_equivalent_p (prevailing_type, type))
+  if (odr_p && !odr_types_equivalent_p (prevailing_type, type))
     lev = 2;
 
   /* Function types needs special care, because types_compatible_p never
@@ -209,15 +219,15 @@ warn_type_compatibility_p (tree prevailing_type, tree type)
          for (parm1 = TYPE_ARG_TYPES (prevailing_type),
               parm2 = TYPE_ARG_TYPES (type);
               parm1 && parm2;
-              parm1 = TREE_CHAIN (prevailing_type),
-              parm2 = TREE_CHAIN (type))
+              parm1 = TREE_CHAIN (parm1),
+              parm2 = TREE_CHAIN (parm2))
            lev |= warn_type_compatibility_p (TREE_VALUE (parm1),
                                              TREE_VALUE (parm2));
          if (parm1 || parm2)
-           lev = 3;
+           lev = odr_p ? 3 : 1;
        }
       if (comp_type_attributes (prevailing_type, type) == 0)
-       lev = 3;
+       lev = odr_p ? 3 : 1;
       return lev;
     }
   /* Sharing a global symbol is a strong hint that two types are
@@ -270,9 +280,6 @@ warn_type_compatibility_p (tree prevailing_type, tree type)
       /* Fallthru.  Compatible enough.  */
     }
 
-  /* ???  We might want to emit a warning here if type qualification
-     differences were spotted.  Do not do this unconditionally though.  */
-
   return lev;
 }