From: Jason Merrill Date: Wed, 22 Nov 2023 18:48:45 +0000 (-0500) Subject: c-family: rename warn_for_address_or_pointer_of_packed_member X-Git-Tag: basepoints/gcc-15~3621 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff35f1d4daa37e74f7a68e87c1a6c180d9a91f10;p=thirdparty%2Fgcc.git c-family: rename warn_for_address_or_pointer_of_packed_member Following the last patch, let's rename the functions to reflect the change in behavior. gcc/c-family/ChangeLog: * c-warn.cc (check_address_or_pointer_of_packed_member): Rename to check_address_of_packed_member. (check_and_warn_address_or_pointer_of_packed_member): Rename to check_and_warn_address_of_packed_member. (warn_for_address_or_pointer_of_packed_member): Rename to warn_for_address_of_packed_member. * c-common.h: Adjust. gcc/c/ChangeLog: * c-typeck.cc (convert_for_assignment): Adjust call to warn_for_address_of_packed_member. gcc/cp/ChangeLog: * call.cc (convert_for_arg_passing) * typeck.cc (convert_for_assignment): Adjust call to warn_for_address_of_packed_member. --- diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 6e7fc1b3aa35..b8bd56c1a4df 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1572,7 +1572,7 @@ extern void warnings_for_convert_and_check (location_t, tree, tree, tree); extern void c_do_switch_warnings (splay_tree, location_t, tree, tree, bool); extern void warn_for_omitted_condop (location_t, tree); extern bool warn_for_restrict (unsigned, tree *, unsigned); -extern void warn_for_address_or_pointer_of_packed_member (tree, tree); +extern void warn_for_address_of_packed_member (tree, tree); extern void warn_parm_array_mismatch (location_t, tree, tree); extern void maybe_warn_sizeof_array_div (location_t, tree, tree, tree, tree); extern void do_warn_array_compare (location_t, tree_code, tree, tree); diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc index 2a399ba6d14d..abe66dd3030e 100644 --- a/gcc/c-family/c-warn.cc +++ b/gcc/c-family/c-warn.cc @@ -2991,13 +2991,13 @@ check_alignment_of_packed_member (tree type, tree field, bool rvalue) return NULL_TREE; } -/* Return struct or union type if the right hand value, RHS +/* Return struct or union type if the right hand value, RHS, is an address which takes the unaligned address of packed member of struct or union when assigning to TYPE. Otherwise, return NULL_TREE. */ static tree -check_address_or_pointer_of_packed_member (tree type, tree rhs) +check_address_of_packed_member (tree type, tree rhs) { bool rvalue = true; bool indirect = false; @@ -3042,14 +3042,12 @@ check_address_or_pointer_of_packed_member (tree type, tree rhs) return context; } -/* Check and warn if the right hand value, RHS: - 1. Is a pointer value which isn't aligned to a pointer type TYPE. - 2. Is an address which takes the unaligned address of packed member - of struct or union when assigning to TYPE. - */ +/* Check and warn if the right hand value, RHS, + is an address which takes the unaligned address of packed member + of struct or union when assigning to TYPE. */ static void -check_and_warn_address_or_pointer_of_packed_member (tree type, tree rhs) +check_and_warn_address_of_packed_member (tree type, tree rhs) { bool nop_p = false; tree orig_rhs; @@ -3067,11 +3065,11 @@ check_and_warn_address_or_pointer_of_packed_member (tree type, tree rhs) if (TREE_CODE (rhs) == COND_EXPR) { /* Check the THEN path. */ - check_and_warn_address_or_pointer_of_packed_member + check_and_warn_address_of_packed_member (type, TREE_OPERAND (rhs, 1)); /* Check the ELSE path. */ - check_and_warn_address_or_pointer_of_packed_member + check_and_warn_address_of_packed_member (type, TREE_OPERAND (rhs, 2)); } else @@ -3095,7 +3093,7 @@ check_and_warn_address_or_pointer_of_packed_member (tree type, tree rhs) } tree context - = check_address_or_pointer_of_packed_member (type, rhs); + = check_address_of_packed_member (type, rhs); if (context) { location_t loc = EXPR_LOC_OR_LOC (rhs, input_location); @@ -3107,14 +3105,12 @@ check_and_warn_address_or_pointer_of_packed_member (tree type, tree rhs) } } -/* Warn if the right hand value, RHS: - 1. Is a pointer value which isn't aligned to a pointer type TYPE. - 2. Is an address which takes the unaligned address of packed member - of struct or union when assigning to TYPE. -*/ +/* Warn if the right hand value, RHS, + is an address which takes the unaligned address of packed member + of struct or union when assigning to TYPE. */ void -warn_for_address_or_pointer_of_packed_member (tree type, tree rhs) +warn_for_address_of_packed_member (tree type, tree rhs) { if (!warn_address_of_packed_member) return; @@ -3123,7 +3119,7 @@ warn_for_address_or_pointer_of_packed_member (tree type, tree rhs) if (!POINTER_TYPE_P (type)) return; - check_and_warn_address_or_pointer_of_packed_member (type, rhs); + check_and_warn_address_of_packed_member (type, rhs); } /* Return EXPR + 1. Convenience helper used below. */ diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 18860c2373fb..022e3c6386ba 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -7000,7 +7000,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype)) { - warn_for_address_or_pointer_of_packed_member (type, orig_rhs); + warn_for_address_of_packed_member (type, orig_rhs); return rhs; } @@ -7658,7 +7658,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, /* If RHS isn't an address, check pointer or array of packed struct or union. */ - warn_for_address_or_pointer_of_packed_member (type, orig_rhs); + warn_for_address_of_packed_member (type, orig_rhs); return convert (type, rhs); } diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index aaee34f35b04..13ca9511cc87 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -9304,7 +9304,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain) } if (complain & tf_warning) - warn_for_address_or_pointer_of_packed_member (type, val); + warn_for_address_of_packed_member (type, val); return val; } diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 258cfd43114d..a6e2f4ee7da8 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -10384,7 +10384,7 @@ convert_for_assignment (tree type, tree rhs, maybe_warn_unparenthesized_assignment (rhs, complain); if (complain & tf_warning) - warn_for_address_or_pointer_of_packed_member (type, rhs); + warn_for_address_of_packed_member (type, rhs); return perform_implicit_conversion_flags (strip_top_quals (type), rhs, complain, flags);