This is a fix for a wrong warning from -Wlto-type-mismatch that reports a type mismatch for two built-in functions.

The avr backend has several built-ins that have the same asm name because their assembler implementation in libgcc is exactly the same. The prototypes might differ, however.

This patch skips the warning for built-in types as discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78562#c6

Testing against avr-unknown-none, this resolves all FAILs because of that warning, e.g. gcc.target/avr/torture/builtins-5-countlsfx.c

Ok for trunk?

Johann

gcc/lto/
        PR lto/78562
        * lto-symtab.c (lto_symtab_merge_decls_2): Don't diagnose type
        mismatch if the two types are built-in.
Index: lto/lto-symtab.c
===================================================================
--- lto/lto-symtab.c	(revision 242823)
+++ lto/lto-symtab.c	(working copy)
@@ -655,6 +655,14 @@ lto_symtab_merge_decls_2 (symtab_node *f
   /* Diagnose all mismatched re-declarations.  */
   FOR_EACH_VEC_ELT (mismatches, i, decl)
     {
+      /* Do not diagnose two built-in declarations, there is no useful
+         location in that case.  It also happens for AVR if two built-ins
+         use the same asm name because their libgcc assembler code is the
+         same, see PR78562.  */
+      if (DECL_IS_BUILTIN (prevailing->decl)
+	  && DECL_IS_BUILTIN (decl))
+	continue;
+
       int level = warn_type_compatibility_p (TREE_TYPE (prevailing->decl),
 					     TREE_TYPE (decl),
 					     DECL_COMDAT (decl));

Reply via email to