aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-04-21 17:06:31 +0200
committerJakub Jelinek <jakub@redhat.com>2020-04-21 17:06:31 +0200
commit73f8e9dca5ff891ed19001b213fd1f6ce31417e3 (patch)
tree672bb597baac2acd957524d5f12db22395dbf327 /gcc/stor-layout.c
parent08d6ec14e654292340ccc6aa5612bbd91d4d57e8 (diff)
downloadgcc-73f8e9dca5ff891ed19001b213fd1f6ce31417e3.zip
gcc-73f8e9dca5ff891ed19001b213fd1f6ce31417e3.tar.gz
gcc-73f8e9dca5ff891ed19001b213fd1f6ce31417e3.tar.bz2
ubsan: Avoid -Wpadded warnings [PR94641]
-Wpadded warnings aren't really useful for the artificial types that GCC lays out for ubsan. 2020-04-21 Jakub Jelinek <jakub@redhat.com> PR c/94641 * stor-layout.c (place_field, finalize_record_size): Don't emit -Wpadded warning on TYPE_ARTIFICIAL rli->t. * ubsan.c (ubsan_get_type_descriptor_type, ubsan_get_source_location_type, ubsan_create_data): Set TYPE_ARTIFICIAL. * asan.c (asan_global_struct): Likewise. * c-c++-common/ubsan/pr94641.c: New test.
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 8c9e034..bde6fa2 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1341,7 +1341,8 @@ place_field (record_layout_info rli, tree field)
Bump the cumulative size to multiple of field alignment. */
if (!targetm.ms_bitfield_layout_p (rli->t)
- && DECL_SOURCE_LOCATION (field) != BUILTINS_LOCATION)
+ && DECL_SOURCE_LOCATION (field) != BUILTINS_LOCATION
+ && !TYPE_ARTIFICIAL (rli->t))
warning (OPT_Wpadded, "padding struct to align %q+D", field);
/* If the alignment is still within offset_align, just align
@@ -1775,7 +1776,8 @@ finalize_record_size (record_layout_info rli)
if (TREE_CONSTANT (unpadded_size)
&& simple_cst_equal (unpadded_size, TYPE_SIZE (rli->t)) == 0
- && input_location != BUILTINS_LOCATION)
+ && input_location != BUILTINS_LOCATION
+ && !TYPE_ARTIFICIAL (rli->t))
warning (OPT_Wpadded, "padding struct size to alignment boundary");
if (warn_packed && TREE_CODE (rli->t) == RECORD_TYPE