From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id 7C2703886C7A; Mon, 7 Jun 2021 16:23:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C2703886C7A MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1264] Fix old thinko in warning on pointer for storage order purposes X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: 6cb35b606c39d5f21f3298c77bfbcaaef3fbc872 X-Git-Newrev: 97d83259b91fb558f5b09bfb09529900f585c4c9 Message-Id: <20210607162312.7C2703886C7A@sourceware.org> Date: Mon, 7 Jun 2021 16:23:12 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2021 16:23:12 -0000 https://gcc.gnu.org/g:97d83259b91fb558f5b09bfb09529900f585c4c9 commit r12-1264-g97d83259b91fb558f5b09bfb09529900f585c4c9 Author: Eric Botcazou Date: Mon Jun 7 18:17:31 2021 +0200 Fix old thinko in warning on pointer for storage order purposes gcc/c PR c/100920 * c-typeck.c (convert_for_assignment): Test fndecl_built_in_p to spot built-in functions. gcc/testsuite/ * gcc.dg/sso-14.c: Adjust. Diff: --- gcc/c/c-typeck.c | 2 +- gcc/testsuite/gcc.dg/sso-14.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index daa2e12a25f..845d50f3310 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -7303,7 +7303,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, /* Do not warn for built-in functions, for example memcpy, since we control how they behave and they can be useful in this area. */ if (TREE_CODE (rname) != FUNCTION_DECL - || !DECL_IS_UNDECLARED_BUILTIN (rname)) + || !fndecl_built_in_p (rname)) warning_at (location, OPT_Wscalar_storage_order, "passing argument %d of %qE from incompatible " "scalar storage order", parmnum, rname); diff --git a/gcc/testsuite/gcc.dg/sso-14.c b/gcc/testsuite/gcc.dg/sso-14.c index af98145569e..8941946c3ab 100644 --- a/gcc/testsuite/gcc.dg/sso-14.c +++ b/gcc/testsuite/gcc.dg/sso-14.c @@ -5,6 +5,7 @@ #include #include +#include #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define REV_ENDIANNESS __attribute__((scalar_storage_order("big-endian"))) @@ -42,12 +43,14 @@ int main(void) { t_s12 *msg1 = __builtin_alloca(10); t_u12 *msg2 = __builtin_alloca(10); + int same; msg1 = malloc (sizeof (t_s12)); msg2 = malloc (sizeof (t_u12)); - msg1->a[0].val = 0; - msg2->a[0].val = 0; + memset (msg1, 0, sizeof (t_s12)); + memcpy (msg2, &msg1, sizeof (t_s12)); + same = memcmp (msg1, msg2, sizeof (t_s12)); return 0; }