Jakub Jelinek ef8af34e0d c++: Implement CWG3131 - Value categories and types for the range in iterable expansion statements
For the https://gcc.gnu.org/pipermail/gcc/2025-November/246977.html
issues I've filed https://github.com/cplusplus/CWG/issues/805
which resulted in two CWG issues,
https://cplusplus.github.io/CWG/issues/3131.html
and
https://cplusplus.github.io/CWG/issues/3140.html
This patch implements the former, changing
the iterating expansion statement http://eel.is/c++draft/stmt.expand#5.2
line from
constexpr auto&& range = expansion-initializer;
to
constexpr decltype(auto) range = (expansion-initializer);
(for our partly pre-CWG3044 implementation with static before it).

2026-01-29  Jakub Jelinek  <jakub@redhat.com>

	* cp-tree.h (build_range_temp): Implement CWG3131 - Value
	categories and types for the range in iterable expansion statements.
	Add bool argument defaulted to false.
	* parser.cc (build_range_temp): Add expansion_stmt_p argument,
	if true build const decltype(auto) __for_range = range_expr instead of
	auto &&__for_range = range_expr.
	(cp_build_range_for_decls): For expansion stmts build __for_range as
	static constexpr decltype(auto) __for_range = (range_expr);
	rather than static constexpr auto &&__for_range = range_expr;.

	* g++.dg/cpp26/expansion-stmt1.C (N::begin, N::end, O::begin,
	O::end): Change argument type from B & to const B & or from
	D & to const D &.
	* g++.dg/cpp26/expansion-stmt2.C (N::begin, N::end, O::begin,
	O::end): Likewise.
	* g++.dg/cpp26/expansion-stmt3.C (N::begin, N::end, O::begin,
	O::end): Likewise.
	* g++.dg/cpp26/expansion-stmt16.C: Expect different diagnostics
	for C++11.
	* g++.dg/cpp26/expansion-stmt18.C (N::begin, N::end): Change
	argument type from B & to const B &.
	* g++.dg/cpp26/expansion-stmt25.C (N::begin, N::end): Likewise.
	* g++.dg/cpp26/expansion-stmt26.C: New test.
	* g++.dg/reflect/p3491-2.C (baz): Move workaround to a new
	function garply, use the previously #if 0 guarded implementation.
	(garply): New function.
2026-01-29 09:49:51 +01:00
2026-01-21 00:16:32 +00:00
2026-01-20 00:16:30 +00:00
2026-01-16 00:16:30 +00:00
2026-01-16 00:16:30 +00:00
2026-01-25 00:16:27 +00:00
2026-01-25 00:16:27 +00:00
2026-01-18 00:16:31 +00:00
2026-01-14 00:16:30 +00:00
2026-01-21 00:16:32 +00:00
2026-01-13 00:16:32 +00:00
2026-01-27 00:16:29 +00:00
2026-01-29 00:16:45 +00:00
2026-01-27 00:16:29 +00:00
2026-01-23 00:16:27 +00:00
2026-01-19 09:56:51 +01:00
2026-01-19 09:56:51 +01:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 2.7 GiB
Languages
C++ 30.7%
C 30.1%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.5%