C++: Fix alias template conversions with capture proxies.
Resolves issues with C++ alias template conversions involving lambda capture proxies.
This commit addresses a problem in C++ alias template conversions where building an IMPLICIT_CONV_EXPR around a capture proxy caused the compiler to lose lambda scope during substitution, leading to errors. The fix ensures that capture proxies are properly resolved to their constant values using mark_rvalue_use and rewrites the conversion to handle NOP_EXPR/CONVERT_EXPR more effectively.
In Details
The tsubst_expr function in pt.cc was incorrectly creating an IMPLICIT_CONV_EXPR around a capture proxy when processing dependent alias template arguments. This wrapper caused the substitution to occur outside the lambda's scope, leading to failures when resolving the captured variable. The fix in convert_nontype_argument_maybe_dependent now correctly resolves the capture using mark_rvalue_use and rewrites the expression to NOP_EXPR or CONVERT_EXPR before applying the implicit conversion, thus maintaining the correct scope.
- alias template
- A C++ template that provides an alias for another template, allowing for more flexible template metaprogramming and type aliasing.
- capture proxy
- An internal representation in GCC used to stand in for a captured variable within a lambda expression before its actual value or type is fully determined.
- IMPLICIT_CONV_EXPR
- An internal GCC expression tree node representing an implicit conversion that the compiler applies to a value.
- lambda scope
- The lexical region associated with a C++ lambda expression, within which its captured variables are accessible.
- substitution
- The process in template metaprogramming where template parameters are replaced with their actual arguments.