diff mbox series

ipa/100791 - copy fntype when processing __builtin_va_arg_pack

Message ID 6750pq7s-oqp5-s2o2-91q6-91496rs1256n@fhfr.qr
State New
Headers show
Series ipa/100791 - copy fntype when processing __builtin_va_arg_pack | expand

Commit Message

Richard Biener May 28, 2021, 12:25 p.m. UTC
This missing copying exposed a type mismatch in the IL.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2021-05-28  Richard Biener  <rguenther@suse.de>

	* tree-inline.c (copy_bb): When processing __builtin_va_arg_pack
	copy fntype from original call.

	* gcc.dg/pr100791.c: New testcase.
---
 gcc/testsuite/gcc.dg/pr100791.c | 9 +++++++++
 gcc/tree-inline.c               | 1 +
 2 files changed, 10 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/pr100791.c
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/pr100791.c b/gcc/testsuite/gcc.dg/pr100791.c
new file mode 100644
index 00000000000..96cf34f14a4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100791.c
@@ -0,0 +1,9 @@ 
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+static inline int __attribute__((__always_inline__))
+foo ()
+{
+  return log_bad_request(0, __builtin_va_arg_pack()); /* { dg-warning "implicit" } */
+}
+void log_bad_request() { foo (0); } /* { dg-warning "conflicting types" } */
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 1d13e7f5aca..d38e8617e3d 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2100,6 +2100,7 @@  copy_bb (copy_body_data *id, basic_block bb,
 		 GF_CALL_VA_ARG_PACK.  */
 	      gimple_call_copy_flags (new_call, call_stmt);
 	      gimple_call_set_va_arg_pack (new_call, false);
+	      gimple_call_set_fntype (new_call, gimple_call_fntype (call_stmt));
 	      /* location includes block.  */
 	      gimple_set_location (new_call, gimple_location (stmt));
 	      gimple_call_set_lhs (new_call, gimple_call_lhs (call_stmt));