From 5b81a980e6949bfb826bf5f0da7180f1f8e559d4 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 2 Jan 2019 22:15:46 +0000 Subject: [PATCH] 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. From-SVN: r267532 --- gcc/cp/ChangeLog | 6 +++ gcc/cp/call.c | 3 +- gcc/cp/typeck.c | 3 +- gcc/testsuite/ChangeLog | 5 +++ .../g++.dg/warn/Waddress-of-packed-member1.C | 42 +++++++++++++++++++ 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/Waddress-of-packed-member1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4c9083a857b..fa03419c53e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-01-02 Marek Polacek + + 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 Update copyright years. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 956d4cf5423..8bc8566e8d6 100644 --- a/gcc/cp/call.c +++ b/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 a/gcc/cp/typeck.c b/gcc/cp/typeck.c index cf3e46fc816..e399cd3fe45 100644 --- a/gcc/cp/typeck.c +++ b/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 a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1d5a8769fae..d2a214b3a1c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-02 Marek Polacek + + PR c++/88612 - ICE with -Waddress-of-packed-member. + * g++.dg/warn/Waddress-of-packed-member1.C: New test. + 2019-01-02 Martin Sebor Jeff Law 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 index 00000000000..8faa046fd92 --- /dev/null +++ b/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 +auto indirect_call(F f, T... t) -> decltype(f(t...)) +{ + return f(t...); +} + +template +struct VariadicBind +{ + F f; + T t; + + template + auto operator()(A... a) -> decltype(indirect_call(f, t, a...)) + { + return indirect_call(f, t, a...); + } +}; + +template +void apply(F f) +{ + f(); +} + +template +void apply(F f, V1 v1, V... v) +{ + apply(VariadicBind{f, v1}, v...); +} + +void func(int, int) { } + +int main() +{ + apply(func, 0, 0); +} -- 2.30.2