]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix old thinko in warning on pointer for storage order purposes
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 7 Jun 2021 16:17:31 +0000 (18:17 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 7 Jun 2021 16:22:29 +0000 (18:22 +0200)
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.

gcc/c/c-typeck.c
gcc/testsuite/gcc.dg/sso-14.c

index daa2e12a25ff5ebb2375ae471c662d0468f13a98..845d50f3310d7d46f13cbc6bbd57ddfbbdffaa15 100644 (file)
@@ -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);
index af98145569e02607f750702d0a608ae313710505..8941946c3ab108aaf9f13bdd0fea41baa07d8d7a 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <stddef.h>
 #include <stdlib.h>
+#include <string.h>
 
 #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;
 }