]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/99959 - handle FRAME in SRA for diagnostics
authorRichard Biener <rguenther@suse.de>
Fri, 13 Feb 2026 08:42:01 +0000 (09:42 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 13 Feb 2026 10:08:55 +0000 (11:08 +0100)
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.

gcc/testsuite/gcc.dg/uninit-pr99959.c [new file with mode: 0644]
gcc/tree-sra.cc

diff --git a/gcc/testsuite/gcc.dg/uninit-pr99959.c b/gcc/testsuite/gcc.dg/uninit-pr99959.c
new file mode 100644 (file)
index 0000000..c8c7461
--- /dev/null
@@ -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;
+}
index 65ae5c99a0babe959a638626f46f226ebfaf068f..7f6d560e429153f993e9b0fa159d5fdd7ee34716 100644 (file)
@@ -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;