From edfcd7e3d471b9dde2d9a84490a850d2f850f381 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 8 Mar 2017 14:10:47 +0000 Subject: [PATCH] re PR tree-optimization/79955 (GLIBC build fails after r245840) 2017-03-08 Richard Biener PR tree-optimization/79955 * tree-ssa-uninit.c (warn_uninitialized_vars): Do not warn for accesses that are completely outside of the variable. * gcc.dg/uninit-24.c: New testcase. From-SVN: r245976 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/uninit-24.c | 10 ++++++++++ gcc/tree-ssa-uninit.c | 11 +++++++++++ 4 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/uninit-24.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 56b22812277..c59224eab39 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-03-08 Richard Biener + + PR tree-optimization/79955 + * tree-ssa-uninit.c (warn_uninitialized_vars): Do not warn + for accesses that are completely outside of the variable. + 2017-03-08 Andrew Haley PR tree-optimization/79943 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5824caf414b..396ab3ad121 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -7,6 +7,11 @@ PR tree-optimization/79943 * gcc.dg/tree-ssa/pr79943.c: New test. +2017-03-08 Richard Biener + + PR tree-optimization/79955 + * gcc.dg/uninit-24.c: New testcase. + 2017-03-08 Richard Biener PR tree-optimization/79920 diff --git a/gcc/testsuite/gcc.dg/uninit-24.c b/gcc/testsuite/gcc.dg/uninit-24.c new file mode 100644 index 00000000000..30fe1e510fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-24.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized" } */ + +int foo (int x) +{ + int y; + if (x) + return *(&y + 1); /* { dg-bogus "may be used uninitialized" } */ + return 0; +} diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 1805c674ea4..e019ecc9d29 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -287,6 +287,17 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized) || TREE_NO_WARNING (base)) continue; + /* Do not warn if the access is fully outside of the + variable. */ + if (ref.size != -1 + && ref.max_size == ref.size + && (ref.offset + ref.size <= 0 + || (ref.offset >= 0 + && TREE_CODE (DECL_SIZE (base)) == INTEGER_CST + && compare_tree_int (DECL_SIZE (base), + ref.offset) <= 0))) + continue; + /* Limit the walking to a constant number of stmts after we overcommit quadratic behavior for small functions and O(n) behavior. */ -- 2.30.2