public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6714] Add test for bogus warning [PR104076].
@ 2022-01-19  1:04 Martin Sebor
  0 siblings, 0 replies; only message in thread
From: Martin Sebor @ 2022-01-19  1:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6325041c2b68af096195e0eef92091b2e293e950

commit r12-6714-g6325041c2b68af096195e0eef92091b2e293e950
Author: Martin Sebor <msebor@redhat.com>
Date:   Tue Jan 18 17:56:20 2022 -0700

    Add test for bogus warning [PR104076].
    
    Related:
    PR middle-end/104076 - bogus -Wdangling-pointer on a conditional
    
    gcc/testsuite/ChangeLog:
            PR middle-end/104076
            * g++.dg/warn/Wdangling-pointer-3.C: New test.

Diff:
---
 gcc/testsuite/g++.dg/warn/Wdangling-pointer-3.C | 39 +++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gcc/testsuite/g++.dg/warn/Wdangling-pointer-3.C b/gcc/testsuite/g++.dg/warn/Wdangling-pointer-3.C
new file mode 100644
index 00000000000..64117bfb65a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wdangling-pointer-3.C
@@ -0,0 +1,39 @@
+/* PR middle-end/104076 - bogus -Wdangling-pointer on a conditional expression
+   { dg-do compile { target { c++11 } } }
+   { dg-options "-Wall" } */
+
+namespace std {
+
+template <class T>
+struct initializer_list
+{
+  T *array;
+  __SIZE_TYPE__ nelts;
+
+  initializer_list (const T *a, __SIZE_TYPE__ n)
+    : array (a), nelts (n) { }
+
+  initializer_list()
+  : array (), nelts () { }
+
+  T* begin () const { return array; }
+
+  const T* end () const { return array + nelts; }
+};
+
+}
+
+struct S1
+{
+  S1 (int);
+  ~S1 ();
+};
+
+struct S2 { S2 (std::initializer_list<S1>); };
+
+S2 f1();
+
+S2 f2(bool b)
+{
+  return b ? f1() : S2{0};    // { dg-bogus "-Wdangling-pointer" }
+}


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

only message in thread, other threads:[~2022-01-19  1:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19  1:04 [gcc r12-6714] Add test for bogus warning [PR104076] 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).