lto-symtab.c (lto_symtab_merge_decls_2): Do not report ODR violations for method...
authorJan Hubicka <hubicka@ucw.cz>
Mon, 24 Dec 2018 11:12:42 +0000 (12:12 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 24 Dec 2018 11:12:42 +0000 (11:12 +0000)
* lto-symtab.c (lto_symtab_merge_decls_2): Do not report ODR violations
for method whose basetype was already reported.

* ipa-devirt.c (odr_type_violation_reported_p): New.
* ipa-utils.h (odr_type_violation_reported_p): Declare.

From-SVN: r267397

gcc/ChangeLog
gcc/ipa-devirt.c
gcc/ipa-utils.h
gcc/lto/ChangeLog
gcc/lto/lto-symtab.c

index 310bbec4f5b8ef087aaa73f3e14c402cceecbaac..77631ac9a21d919f9d05e4813a73111e7e5a0134 100644 (file)
@@ -1,3 +1,10 @@
+2018-12-24  Jan Hubicka  <hubicka@ucw.cz>
+
+       * lto-symtab.c (lto_symtab_merge_decls_2): Do not report ODR violations
+       for method whose basetype was already reported.
+       * ipa-devirt.c (odr_type_violation_reported_p): New.
+       * ipa-utils.h (odr_type_violation_reported_p): Declare.
+
 2018-12-24  Iain Sandoe  <iain@sandoe.co.uk>
 
        * configure.ac (dwarf2_debug_line): Check for the debug_line
index ac907aa5fd2b2649ec82c0ae72d87f340123779e..0f42d124fe3d941e946cc75b49a19d69e34abfea 100644 (file)
@@ -2152,6 +2152,12 @@ get_odr_type (tree type, bool insert)
   return val;
 }
 
+bool
+odr_type_violation_reported_p (tree type)
+{
+  return get_odr_type (type, false)->odr_violated;
+}
+
 /* Add TYPE od ODR type hash.  */
 
 void
index 371b2fbdb98b71a59f02b61fcd8cae1f9017ce83..b58693528d83668929fe014546815aa09e811b59 100644 (file)
@@ -90,6 +90,7 @@ void warn_types_mismatch (tree t1, tree t2, location_t loc1 = UNKNOWN_LOCATION,
                          location_t loc2 = UNKNOWN_LOCATION);
 bool odr_or_derived_type_p (const_tree t);
 bool odr_types_equivalent_p (tree type1, tree type2);
+bool odr_type_violation_reported_p (tree type);
 
 /* Return vector containing possible targets of polymorphic call E.
    If COMPLETEP is non-NULL, store true if the list is complete. 
index 7b9846cd8f6ee961faefadf2056086c92fc5154e..ca2f01fed35496bf2630dff959edcc0a965bbd83 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-24  Jan Hubicka  <hubicka@ucw.cz>
+
+       * lto-symtab.c (lto_symtab_merge_decls_2): Do not report ODR violations
+       for method whose basetype was already reported.
+
 2018-11-30  Michael Ploujnikov  <michael.ploujnikov@oracle.com>
 
        Minimize clone counter memory usage in LTO.
index d018a16bd42985fa745de245352d715e0c5e8329..6b981d403ed0dbba5f108c5673f5603e4aeda405 100644 (file)
@@ -697,10 +697,21 @@ lto_symtab_merge_decls_2 (symtab_node *first, bool diagnosed_p)
        {
          bool diag = false;
          if (level & 2)
-           diag = warning_at (DECL_SOURCE_LOCATION (decl),
-                              OPT_Wodr,
-                              "%qD violates the C++ One Definition Rule",
-                              decl);
+           {
+             /* Silence warning for method and variables which belong
+                to types which already have ODR violation reported.  Complaining
+                once is enough.  */
+             if (TREE_CODE (decl) != FUNCTION_DECL
+                 || TREE_CODE (TREE_TYPE (decl)) != METHOD_TYPE
+                 || !TYPE_METHOD_BASETYPE (TREE_TYPE (decl))
+                 || !odr_type_p (TYPE_METHOD_BASETYPE (TREE_TYPE (decl)))
+                 || !odr_type_violation_reported_p 
+                       (TYPE_METHOD_BASETYPE (TREE_TYPE (decl))))
+               diag = warning_at (DECL_SOURCE_LOCATION (decl),
+                                  OPT_Wodr,
+                                  "%qD violates the C++ One Definition Rule",
+                                  decl);
+           }
          if (!diag && (level & 1))
            diag = warning_at (DECL_SOURCE_LOCATION (decl),
                               OPT_Wlto_type_mismatch,