PR c++/88612 - ICE with -Waddress-of-packed-member.
authorMarek Polacek <polacek@redhat.com>
Wed, 2 Jan 2019 22:15:46 +0000 (22:15 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 2 Jan 2019 22:15:46 +0000 (22:15 +0000)
* 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.

From-SVN: r267532

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Waddress-of-packed-member1.C [new file with mode: 0644]

index 4c9083a857bebc905d6202427123b0c4b17f168b..fa03419c53ec7f87d86dba86507ad4bd9f0b7bc6 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-02  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.
+
 2019-01-01  Jakub Jelinek  <jakub@redhat.com>
 
        Update copyright years.
index 956d4cf5423f48925f154a010cf6a90daf7211cd..8bc8566e8d64b50a8ca65e9710cb971229361fac 100644 (file)
@@ -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;
 }
index cf3e46fc816f28c1083a16551057c8dd56ba3980..e399cd3fe45b40962fa6530989642877ba8234d7 100644 (file)
@@ -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);
index 1d5a8769faeb1da1a6eacacff6e7232096b16097..d2a214b3a1c77321a33f295bc1cf7c1c67963fd8 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-02  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/88612 - ICE with -Waddress-of-packed-member.
+       * g++.dg/warn/Waddress-of-packed-member1.C: New test.
+
 2019-01-02  Martin Sebor  <msebor@redhat.com>
             Jeff Law  <law@redhat.com>
 
diff --git a/gcc/testsuite/g++.dg/warn/Waddress-of-packed-member1.C b/gcc/testsuite/g++.dg/warn/Waddress-of-packed-member1.C
new file mode 100644 (file)
index 0000000..8faa046
--- /dev/null
@@ -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);
+}