From: Richard Biener Date: Thu, 22 Sep 2022 13:18:47 +0000 (+0200) Subject: tree-optimization/102801 - testcase for uninit diagnostic X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=44dba051d72587828882cbb31118934a4fb06c1a;p=platform%2Fupstream%2Fgcc.git tree-optimization/102801 - testcase for uninit diagnostic The following testcase is fixed in GCC 12+ PR tree-optimization/102801 gcc/testsuite/ * g++.dg/warn/Wuninitialized-33.C: New testcase. --- diff --git a/gcc/testsuite/g++.dg/warn/Wuninitialized-33.C b/gcc/testsuite/g++.dg/warn/Wuninitialized-33.C new file mode 100644 index 0000000..1bb0639 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wuninitialized-33.C @@ -0,0 +1,55 @@ +// PR102801 +// { dg-do compile } +// { dg-require-effective-target c++17 } +// { dg-options "-O2 -Wall" } + +#include +#include +#include +#include +#include +#include + +class C { + bool b{}; // { dg-bogus "uninitialized" } + + struct Shared {}; + using SharedPtr = std::shared_ptr; + + SharedPtr shared; + +public: + C() = delete; + C(bool bIn) : b(bIn) {} + ~C(); + int someMethod() const; +}; + +using OptC = std::optional; + +class C2 { + OptC c; +public: + C2() = default; + C2(const C &cIn) : c(cIn) {} + ~C2(); + void operator()() const; + void swap(C2 &o) { std::swap(c, o.c); } +}; + + +template +class Q { + std::vector queue; +public: + void Add(std::vector &items) { + for (T & item : items) { + queue.push_back(T()); + item.swap(queue.back()); + } + } + void Exec(); +}; + +extern void foo(Q & q, std::vector &items); +void foo(Q & q, std::vector &items) { q.Add(items); q.Exec(); }