Files
gcc-reflection/gcc/testsuite/g++.dg/modules/lambda-11_b.C
Nathaniel Shead cc79849cc8 c++: Fix canonical type for lambda pack captures [PR122015]
comp_template_parms_position uses whether a TEMPLATE_TYPE_PARM is a pack
to determine equivalency.  This in turn affects whether
canonical_type_parameter finds a pre-existing auto type as equivalent.

When generating the 'auto...' type for a lambda pack capture, we only
mark it as a pack after generating the node (and calculating its
canonical); this means that later when comparing a version streamed in
from a module we think that two equivalent types have different
TYPE_CANONICAL, because the latter already had
TEMPLATE_PARM_PARAMETER_PACK set before calculating its canonical.

This patch fixes this by using a new 'make_auto_pack' function to ensure
that packness is set before the canonical is looked up.

	PR c++/122015

gcc/cp/ChangeLog:

	* cp-tree.h (make_auto_pack): Declare.
	* lambda.cc (lambda_capture_field_type): Use make_auto_pack to
	ensure TYPE_CANONICAL is set correctly.
	* pt.cc (make_auto_pack): New function.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/lambda-11.h: New test.
	* g++.dg/modules/lambda-11_a.H: New test.
	* g++.dg/modules/lambda-11_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
2025-09-23 09:25:00 +10:00

7 lines
161 B
C

// PR c++/122015
// { dg-do compile { target c++20 } }
// { dg-additional-options "-fmodules -fno-module-lazy" }
#include "lambda-11.h"
import "lambda-11_a.H";