c++: Fix structured binding mangling during error recovery [PR126057]
Compiler fix prevents internal compiler errors during error recovery when mangling structured bindings.
This commit addresses an internal compiler error (ICE) that occurred during error recovery when mangling structured bindings. Previously, if a structured binding declaration had errors, its mangling could fail. The fix ensures that in error recovery scenarios, the assembler name is set to <decomp>, preventing mangling for erroneous static block-scope structured bindings and during instantiation when tsubst_decomp_names fails.
In Details
The fix in cp_finish_decomp and tsubst_stmt prevents an ICE when mangling structured bindings during error recovery. For erroneous declarations, TREE_STATIC bases now also get their assembler name set to <decomp>, similar to DECL_NAMESPACE_SCOPE_P bases. Additionally, if tsubst_decomp_names fails during instantiation, the assembler name is set to <decomp> to avoid subsequent mangling issues. This resolves PR126057.
- ICE
- Internal Compiler Error. A condition where the compiler encounters an unrecoverable state and terminates abnormally, typically due to a bug in the compiler itself.
- mangling
- The process of encoding additional information into symbol names (e.g., function names, variable names) to support features like function overloading and namespaces. In C++, this is known as name mangling.
- structured binding
- A C++ language feature (introduced in C++17) that allows decomposing an object (like a tuple, struct, or array) into individual variable names.
- assembler name
- The name given to a symbol (like a function or variable) that will be represented in the generated assembly code and symbol table. This is often determined by the compiler's mangling process.