public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/88612, ICE with -Waddress-of-packed-member
@ 2018-12-31 17:18 Marek Polacek
  2019-01-02 21:32 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2018-12-31 17:18 UTC (permalink / raw)
  To: GCC Patches, Jason Merrill

This new warning was missing tf_warning checks so we may've wound up
re-entering the reporting routines.  Fixed thus.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2018-12-31  Marek Polacek  <polacek@redhat.com>

	PR c++/88612 - ICE with -Waddress-of-packed-member.
	* call.c (convert_for_arg_passing): Only give warnings with tf_warning.
	* typeck.c (convert_for_assignment): Likewise.

	* g++.dg/warn/Waddress-of-packed-member1.C: New test.

diff --git gcc/cp/call.c gcc/cp/call.c
index cd220d70df5..da05cb9bd4e 100644
--- gcc/cp/call.c
+++ gcc/cp/call.c
@@ -7630,7 +7630,8 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain)
       maybe_warn_parm_abi (type, cp_expr_loc_or_loc (val, input_location));
     }
 
-  warn_for_address_or_pointer_of_packed_member (false, type, val);
+  if (complain & tf_warning)
+    warn_for_address_or_pointer_of_packed_member (false, type, val);
 
   return val;
 }
diff --git gcc/cp/typeck.c gcc/cp/typeck.c
index d5d1115fd23..c4fb834fedc 100644
--- gcc/cp/typeck.c
+++ gcc/cp/typeck.c
@@ -9073,7 +9073,8 @@ convert_for_assignment (tree type, tree rhs,
       TREE_NO_WARNING (rhs) = 1;
     }
 
-  warn_for_address_or_pointer_of_packed_member (false, type, rhs);
+  if (complain & tf_warning)
+    warn_for_address_or_pointer_of_packed_member (false, type, rhs);
 
   return perform_implicit_conversion_flags (strip_top_quals (type), rhs,
 					    complain, flags);
diff --git gcc/testsuite/g++.dg/warn/Waddress-of-packed-member1.C gcc/testsuite/g++.dg/warn/Waddress-of-packed-member1.C
new file mode 100644
index 00000000000..8faa046fd92
--- /dev/null
+++ gcc/testsuite/g++.dg/warn/Waddress-of-packed-member1.C
@@ -0,0 +1,42 @@
+// PR c++/88612
+// { dg-do compile { target c++11 } }
+// { dg-options "-fpack-struct -Waddress-of-packed-member" }
+// { dg-prune-output "taking address of packed member" }
+
+template<class F, class... T>
+auto indirect_call(F f, T... t) -> decltype(f(t...))
+{
+  return f(t...);
+}
+
+template<class F, class T>
+struct VariadicBind
+{
+  F f;
+  T t;
+
+  template<class... A>
+  auto operator()(A... a) -> decltype(indirect_call(f, t, a...))
+  {
+    return indirect_call(f, t, a...);
+  }
+};
+
+template<class F>
+void apply(F f)
+{
+  f();
+}
+
+template<class F, class V1, class... V>
+void apply(F f, V1 v1, V... v)
+{
+  apply(VariadicBind<F, int>{f, v1}, v...);
+}
+
+void func(int, int) { }
+
+int main()
+{
+  apply(func, 0, 0);
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: C++ PATCH for c++/88612, ICE with -Waddress-of-packed-member
  2018-12-31 17:18 C++ PATCH for c++/88612, ICE with -Waddress-of-packed-member Marek Polacek
@ 2019-01-02 21:32 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2019-01-02 21:32 UTC (permalink / raw)
  To: Marek Polacek, GCC Patches

On 12/31/18 10:13 AM, Marek Polacek wrote:
> This new warning was missing tf_warning checks so we may've wound up
> re-entering the reporting routines.  Fixed thus.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

OK.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-02 21:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-31 17:18 C++ PATCH for c++/88612, ICE with -Waddress-of-packed-member Marek Polacek
2019-01-02 21:32 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).