public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [pushed] c++: extend Wdangling-reference17.C [PR109642]
Date: Mon, 22 Jan 2024 16:16:05 -0500	[thread overview]
Message-ID: <20240122211605.25352-1-polacek@redhat.com> (raw)

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


                 reply	other threads:[~2024-01-22 21:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240122211605.25352-1-polacek@redhat.com \
    --to=polacek@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).