aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2018-08-28 19:09:38 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2018-08-28 13:09:38 -0600
commit0aaafa5e95df44eed3ad67ea65c9afda2dbdd493 (patch)
treedbf4c33008642719c398d068222b45cd34a970c4 /gcc/stor-layout.c
parentdd35da2cbef6d8bf9db86d7e66faeebb5022c881 (diff)
downloadgcc-0aaafa5e95df44eed3ad67ea65c9afda2dbdd493.zip
gcc-0aaafa5e95df44eed3ad67ea65c9afda2dbdd493.tar.gz
gcc-0aaafa5e95df44eed3ad67ea65c9afda2dbdd493.tar.bz2
PR middle-end/86631 - missing -Walloc-size-larger-than on ILP32 hosts
gcc/ChangeLog: PR middle-end/86631 * calls.c (alloc_max_size): Treat HOST_WIDE_INT special. * gimple-ssa-warn-alloca.c (adjusted_warn_limit): New function. (pass_walloca::gate): Use it. (alloca_call_type): Same. (pass_walloca::execute): Same. * stor-layout.c (layout_decl): Treat HOST_WIDE_INT special. gcc/testsuite/ChangeLog: PR middle-end/86631 * g++.dg/Walloca1.C: Adjust. From-SVN: r263928
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c19
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);
}
}