diff mbox

[lto] Fix PR78562: Wrong type mismatch warning for built-ins with same asm name.

Message ID 1058a106-2dc6-095d-9f82-e5add2edce2e@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay Nov. 29, 2016, 10:16 a.m. UTC
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.

Comments

Richard Biener Nov. 30, 2016, 8:52 a.m. UTC | #1
On Tue, 29 Nov 2016, Georg-Johann Lay wrote:

> 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?

Ok.

Thanks,
Richard.

> 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.
>
diff mbox

Patch

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));