public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] c++: extend Wdangling-reference17.C [PR109642]
@ 2024-01-22 21:16 Marek Polacek
  0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2024-01-22 21:16 UTC (permalink / raw)
  To: GCC Patches

Tested x86_64-pc-linux-gnu, applying to trunk.

-- >8 --
This patch extends g++.dg/warn/Wdangling-reference17.C with code
from PR109642.  I'm not creating a new test because this one
already #includes the required headers.

	PR c++/109642

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wdangling-reference17.C: Additional testing.
---
 gcc/testsuite/g++.dg/warn/Wdangling-reference17.C | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gcc/testsuite/g++.dg/warn/Wdangling-reference17.C b/gcc/testsuite/g++.dg/warn/Wdangling-reference17.C
index 223698422c2..8cda5dea444 100644
--- a/gcc/testsuite/g++.dg/warn/Wdangling-reference17.C
+++ b/gcc/testsuite/g++.dg/warn/Wdangling-reference17.C
@@ -4,6 +4,7 @@
 
 #include <vector>
 #include <ranges>
+#include <span>
 
 int main()
 {
@@ -12,4 +13,15 @@ int main()
     {
       (void) i;
     }
+
+  // From c++/109642.
+  const auto vec = std::vector{ 1, 2, 3 };
+  const auto s = std::span<decltype(vec)::value_type const>{vec};
+
+  for ([[maybe_unused]] auto _ : s | std::views::take(2)) { }
+
+  for ([[maybe_unused]] auto _ : vec | std::views::take(2)) { }
+
+  const auto s_view = s | std::views::take(2);
+  for ([[maybe_unused]] auto _ : s_view) { }
 }

base-commit: bc77c035c45bb224790b1c03d06a64c8a1cc51c5
-- 
2.43.0


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

only message in thread, other threads:[~2024-01-22 21:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-22 21:16 [pushed] c++: extend Wdangling-reference17.C [PR109642] Marek Polacek

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).