From ab3c292e600b31177c8ddfe1e7a1cda255d39321 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Thu, 20 Dec 2018 16:25:13 +0000 Subject: [PATCH] PR tree-optimization/84053 - missing -Warray-bounds accessing a local array across inlined function boundaries gcc/testsuite/ChangeLog: * gcc.dg/Warray-bounds-36.c: New test. From-SVN: r267302 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/Warray-bounds-36.c | 27 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/Warray-bounds-36.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 61aa13ba5b6..2a78f9722a9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-20 Martin Sebor + + PR tree-optimization/84053 + * gcc.dg/Warray-bounds-36.c: New test. + 2018-12-20 David Malcolm PR c++/87504 diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-36.c b/gcc/testsuite/gcc.dg/Warray-bounds-36.c new file mode 100644 index 00000000000..35b3c9299c7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-36.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/84053] missing -Warray-bounds accessing + a local array across inlined function boundaries + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +int deref (const int *p, int i) +{ + return p[i]; // { dg-warning "array subscript \\\[3, \[0-9\]+] is outside array bounds of .int\\\[2\\\]." "ilp33" { xfail ilp32 } } + + // There should also be an inlining context here. PR 86650 tracks + // its absence. +} + +int deref_3_plus (const int *p, int i) +{ + if (i < 3) + i = 3; + + return deref (p, i); +} + +int deref_a (int i) +{ + int a[] = { 2, 3 }; + + return deref_3_plus (a, i); +} -- 2.30.2