public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-7899] PR tree-optimization/61869 - Spurious uninitialized warning
@ 2021-03-29 22:01 Martin Sebor
  0 siblings, 0 replies; only message in thread
From: Martin Sebor @ 2021-03-29 22:01 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:af739c8797d4cdf550366d0ef48136e0073df5c9

commit r11-7899-gaf739c8797d4cdf550366d0ef48136e0073df5c9
Author: Martin Sebor <msebor@redhat.com>
Date:   Mon Mar 29 15:58:01 2021 -0600

    PR tree-optimization/61869 - Spurious uninitialized warning
    
    gcc/testsuite/ChangeLog:
            PR tree-optimization/61869
            * gcc.dg/uninit-pr61869.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/uninit-pr61869.c | 47 +++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/uninit-pr61869.c b/gcc/testsuite/gcc.dg/uninit-pr61869.c
new file mode 100644
index 00000000000..ef4f4364471
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr61869.c
@@ -0,0 +1,47 @@
+/* PR tree-optimization/61869 - Spurious uninitialized warning (lim1 pass,
+   pretty-printed internal var
+   { dg-do compile }
+   { dg-options "-O2 -Wall" } */
+
+typedef struct data {
+  struct data *next;
+} data;
+
+typedef struct list {
+  unsigned dummy;
+  struct list *next;
+  data *start;
+  int flags;
+} list;
+
+typedef struct iterator {
+  struct data *ptr;
+  unsigned dummy;
+} iterator;
+
+iterator start (list *a) {
+  iterator i = {
+    *(a->flags ? &a->start : 0),
+    0
+  };
+  return i;
+}
+
+void g (iterator *i);
+
+void f (list *b)
+{
+  list *a;
+  iterator i;       // { dg-bogus "-Wmaybe-uninitialized" }
+
+  for (a = b; a; a = a->next)
+  for (i = start (a); i.ptr; i.ptr = i.ptr->next)
+   {
+     if (i.ptr)
+       return;
+   }
+
+  for (a = b; a; a = a->next)
+  for (i = start (a); i.ptr; i.ptr = i.ptr->next)
+    g(&i);
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-29 22:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-29 22:01 [gcc r11-7899] PR tree-optimization/61869 - Spurious uninitialized warning Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).