From af739c8797d4cdf550366d0ef48136e0073df5c9 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Mon, 29 Mar 2021 15:58:01 -0600 Subject: [PATCH] PR tree-optimization/61869 - Spurious uninitialized warning gcc/testsuite/ChangeLog: PR tree-optimization/61869 * gcc.dg/uninit-pr61869.c: New test. --- gcc/testsuite/gcc.dg/uninit-pr61869.c | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/uninit-pr61869.c diff --git a/gcc/testsuite/gcc.dg/uninit-pr61869.c b/gcc/testsuite/gcc.dg/uninit-pr61869.c new file mode 100644 index 0000000..ef4f436 --- /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); +} -- 2.7.4