summaryrefslogtreecommitdiff
path: root/lto-plugin
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-01-12 21:12:05 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-01-17 03:39:01 -0800
commit54b68f11c18971d1371d5bb5bde7b0c1d3e6ee7b (patch)
tree2cc1e5a140dbb42fd50d9f7f6d4c3dacde094aab /lto-plugin
parent323d2aadd7e33c2ed57a1809b50b62a66e8d0f81 (diff)
downloadgcc-hjl/pr51628/master.tar.gz
C/C++: Add -Waddress-of-packed-memberhjl/pr51628/master
When address of packed member of struct or union is taken, it may result in an unaligned pointer value. This patch adds -Waddress-of-packed-member to warn it: $ cat x.i struct pair_t { char c; int i; } __attribute__ ((packed)); extern struct pair_t p; int *addr = &p.i; $ gcc -O2 -S x.i x.i:8:13: warning: initialization of 'int *' from address of packed member of 'struct pair_t' may result in an unaligned pointer value [-Waddress-of-packed-member] int *addr = &p.i; ^ $ This warning is enabled by default. gcc/c/ PR c/51628 * doc/invoke.texi: Document -Wno-address-of-packed-member. gcc/c-family/ PR c/51628 * c-common.h (warn_for_address_of_packed_member): New. * c-warn.c (warn_for_address_of_packed_member): New function. * c.opt: Add -Wno-address-of-packed-member. gcc/c/ PR c/51628 * c-typeck.c (convert_for_assignment): Call warn_for_address_of_packed_member. Issue an warning if address of packed member is taken. gcc/cp/ PR c/51628 * call.c (convert_for_arg_passing): Call warn_for_address_of_packed_member. Issue an warning if address of packed member is taken. * typeck.c (convert_for_assignment): Likewise. gcc/testsuite/ PR c/51628 * c-c++-common/pr51628-1.c: New tests. * c-c++-common/pr51628-10.c: Likewise. * c-c++-common/pr51628-2.c: Likewise. * c-c++-common/pr51628-3.c: Likewise. * c-c++-common/pr51628-4.c: Likewise. * c-c++-common/pr51628-5.c: Likewise. * c-c++-common/pr51628-6.c: Likewise. * c-c++-common/pr51628-7.c: Likewise. * c-c++-common/pr51628-8.c: Likewise. * c-c++-common/pr51628-9.c: Likewise. * gcc.dg/pr51628-10.c: Likewise. * gcc.dg/pr51628-11.c: Likewise. * c-c++-common/ubsan/align-10.c: Add -Wno-address-of-packed-member. * c-c++-common/ubsan/align-2.c: Likewise. * c-c++-common/ubsan/align-4.c: Likewise. * c-c++-common/ubsan/align-6.c: Likewise. * c-c++-common/ubsan/align-7.c: Likewise. * c-c++-common/ubsan/align-8.c: Likewise. * g++.dg/ubsan/align-2.C: Likewise. * gcc.target/i386/avx512bw-vmovdqu16-2.c: Likewise. * gcc.target/i386/avx512f-vmovdqu32-2.c: Likewise. * gcc.target/i386/avx512f-vmovdqu64-2.c: Likewise. * gcc.target/i386/avx512vl-vmovdqu16-2.c: Likewise. * gcc.target/i386/avx512vl-vmovdqu32-2.c: Likewise. * gcc.target/i386/avx512vl-vmovdqu64-2.c: Likewise.
Diffstat (limited to 'lto-plugin')
0 files changed, 0 insertions, 0 deletions