diff options
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 85937d0..088f360 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -760,14 +760,19 @@ layout_decl (tree decl, unsigned int known_align) { tree size = DECL_SIZE_UNIT (decl); - if (size != 0 && TREE_CODE (size) == INTEGER_CST - && compare_tree_int (size, warn_larger_than_size) > 0) + if (size != 0 && TREE_CODE (size) == INTEGER_CST) { - unsigned HOST_WIDE_INT uhwisize = tree_to_uhwi (size); - - warning (OPT_Wlarger_than_, "size of %q+D %wu bytes exceeds " - "maximum object size %wu", - decl, uhwisize, warn_larger_than_size); + /* -Wlarger-than= argument of HOST_WIDE_INT_MAX is treated + as if PTRDIFF_MAX had been specified, with the value + being that on the target rather than the host. */ + unsigned HOST_WIDE_INT max_size = warn_larger_than_size; + if (max_size == HOST_WIDE_INT_MAX) + max_size = tree_to_shwi (TYPE_MAX_VALUE (ptrdiff_type_node)); + + if (compare_tree_int (size, max_size) > 0) + warning (OPT_Wlarger_than_, "size of %q+D %E bytes exceeds " + "maximum object size %wu", + decl, size, max_size); } } |