Files
Jakub Jelinek 0f5760d599 c++: Fix up expansion statement handling
I've noticed that in many spots of the expansion statement handling I've
handled incorrectly the creation of VAR_DECLs which are constexpr
in the spec (or can be constexpr when user writes it that way).
All I've done was set DECL_DECLARED_CONSTEXPR_P and TREE_READONLY
flags on the VAR_DECL, but haven't made sure the TREE_TYPE is const
qualified as well (with the exception of references obviously).
Haven't touched spots which are always references, e.g. when it is
constexpr auto &&var etc.

Fixing this revealed some problems:
1) one fixed by first hunk in pt.cc, where the i variable was created
with get_target_expr and thus now is const as well and so operator++
on it doesn't work; used build_target_expr_with_type to make it
non-const
2) several tests got it wrong and didn't actually support calling
operator *, operator != and operator + on const objects; fixed by
making those operators const qualified.

2025-12-19  Jakub Jelinek  <jakub@redhat.com>

	* parser.cc (cp_build_range_for_decls): If expansion_stmt_p,
	where we are setting DECL_DECLARED_CONSTEXPR_P on begin/end, use
	const qualified iter_type.
	* pt.cc (finish_expansion_stmt): Use build_target_expr_with_type
	with cv_unqualified to create it instead of get_target_expr to
	make it non-const qualified.  When creating VAR_DECLs with
	DECL_DECLARED_CONSTEXPR_P, make sure they have const qualified
	type unless they are references.

	* g++.dg/cpp26/expansion-stmt1.C (A::operator *, A::operator !=,
	A::operator +, C::operator *, C::operator !=, C::operator +): Add
	const qualification.
	* g++.dg/cpp26/expansion-stmt2.C (A::operator *, A::operator !=,
	A::operator +, C::operator *, C::operator !=, C::operator +):
	Likewise.
	* g++.dg/cpp26/expansion-stmt3.C (A::operator *, A::operator !=,
	A::operator +, C::operator *, C::operator !=, C::operator +):
	Likewise.
	* g++.dg/cpp26/expansion-stmt18.C (A::operator *, A::operator !=,
	A::operator +): Likewise.
2025-12-19 10:12:06 +01:00
..
2025-07-31 10:40:28 -04:00
2025-07-31 10:40:28 -04:00
2025-07-31 10:40:28 -04:00
2025-07-31 10:40:28 -04:00
2025-07-31 10:40:28 -04:00
2025-07-31 10:40:28 -04:00
2025-07-31 10:40:28 -04:00
2025-07-31 10:40:28 -04:00