From: Richard Biener Date: Fri, 13 Feb 2026 08:42:01 +0000 (+0100) Subject: tree-optimization/99959 - handle FRAME in SRA for diagnostics X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f9a973a3fdd59076d23b34d95f96d7c581f3968;p=thirdparty%2Fgcc.git tree-optimization/99959 - handle FRAME in SRA for diagnostics The following includes DECL_NONLOCAL_FRAME in the processing for setting debug expressions on access replacements, avoiding disabling diagnostics. PR tree-optimization/99959 * tree-sra.cc (create_access_replacement): Always create debug expressions for DECL_NONLOCAL_FRAME bases. * gcc.dg/uninit-pr99959.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/uninit-pr99959.c b/gcc/testsuite/gcc.dg/uninit-pr99959.c new file mode 100644 index 00000000000..c8c74617b8e --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-pr99959.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +void g (void) +{ + int i; + + void f (int *t) + { + __builtin_printf ("%i", i); /* { dg-warning "is used uninitialized" } */ + } + + int t __attribute__ ((cleanup (f))) = 0; +} diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc index 65ae5c99a0b..7f6d560e429 100644 --- a/gcc/tree-sra.cc +++ b/gcc/tree-sra.cc @@ -2588,8 +2588,8 @@ create_access_replacement (struct access *access, tree reg_type = NULL_TREE) DECL_IGNORED_P (repl) = DECL_IGNORED_P (access->base); if (DECL_NAME (access->base) - && !DECL_IGNORED_P (access->base) - && !DECL_ARTIFICIAL (access->base)) + && ((!DECL_IGNORED_P (access->base) && !DECL_ARTIFICIAL (access->base)) + || DECL_NONLOCAL_FRAME (access->base))) { char *pretty_name = make_fancy_name (access->expr); tree debug_expr = unshare_expr_without_location (access->expr), d;