diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2025-09-02 15:58:26 -0700 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2025-09-02 15:58:26 -0700 |
commit | 071b4126c613881f4cb25b4e5c39032964827f88 (patch) | |
tree | 7ed805786566918630d1d617b1ed8f7310f5fd8e /gcc/testsuite/gcc.dg/pr109071_10.c | |
parent | 845d23f3ea08ba873197c275a8857eee7edad996 (diff) | |
parent | caa1c2f42691d68af4d894a5c3e700ecd2dba080 (diff) | |
download | gcc-devel/gfortran-test.zip gcc-devel/gfortran-test.tar.gz gcc-devel/gfortran-test.tar.bz2 |
Merge branch 'master' into gfortran-testdevel/gfortran-test
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr109071_10.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/pr109071_10.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr109071_10.c b/gcc/testsuite/gcc.dg/pr109071_10.c new file mode 100644 index 0000000..1fe7edc --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr109071_10.c @@ -0,0 +1,85 @@ +/* PR tree-optimization/109071 need more context for -Warray-bounds warnings + due to compiler optimization. */ +/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=3" } */ +/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */ +/* { dg-enable-nn-line-numbers "" } */ +#define MAX_LENGTH 10 +int a[MAX_LENGTH]; + +void __attribute__ ((noinline)) foo (int i, bool is_dollar) +{ + if (i < MAX_LENGTH) + { + if (i == -1) + { + if (is_dollar) + __builtin_printf ("dollar"); + else + __builtin_printf ("euro"); + a[i] = -1; /* { dg-warning "is below array bounds of" } */ + } + else + a[i] = i; + } + else + a[i] = i + 1; /* { dg-warning "is above array bounds of" } */ +} + +int main () +{ + for (int i = 0; i < MAX_LENGTH; i++) + foo (i, true); + return 0; +} + +/* { dg-begin-multiline-output "" } + NN | a[i] = i + 1; + | ~^~~ + 'foo': events 1-2 + NN | if (i < MAX_LENGTH) + | ^ + | | + | (1) when the condition is evaluated to false +...... + { dg-end-multiline-output "" } */ + +/* { dg-begin-multiline-output "" } + NN | a[i] = i + 1; + | ~~~~ + | | + | (2) warning happens here + { dg-end-multiline-output "" } */ + +/* { dg-begin-multiline-output "" } + NN | int a[MAX_LENGTH]; + | ^ + { dg-end-multiline-output "" } */ + +/* { dg-begin-multiline-output "" } + NN | a[i] = -1; + | ~^~~ + 'foo': events 1-3 + NN | if (i < MAX_LENGTH) + | ~ + | | + | (2) when the condition is evaluated to true + NN | { + NN | if (i == -1) + | ^ + | | + | (1) when the condition is evaluated to true +...... + { dg-end-multiline-output "" } */ + +/* { dg-begin-multiline-output "" } + NN | a[i] = -1; + | ~~~~ + | | + | (3) warning happens here + { dg-end-multiline-output "" } */ + +/* { dg-begin-multiline-output "" } + NN | int a[MAX_LENGTH]; + | ^ + { dg-end-multiline-output "" } */ + |