C++ structured binding size trait handled correctly
Ensures C++ structured binding size trait is correctly checked, fixing issues with non-class types and arrays.
This commit corrects the C++ frontend’s handling of the CPTK_STRUCTURED_BINDING_SIZE trait, particularly for non-class types and arrays. Previously, the compiler might reject valid code if the type wasn’t already instantiated. The fix involves calling check_trait_type appropriately and simplifying trait expression handling, resolving a bug reported in PR127766.
In Details
The GCC C++ frontend's implementation of CPTK_STRUCTURED_BINDING_SIZE trait resolution in semantics.cc and pt.cc was incomplete. It failed to correctly delegate type completion to check_trait_type for certain types (e.g., non-class types, arrays), leading to false rejections. This change ensures check_trait_type is invoked with the correct parameters, resolving PR127766, and removes special casing in tsubst_expr for improved consistency.
- CPTK_STRUCTURED_BINDING_SIZE
- A compiler-internal constant representing the trait that queries the size of a structured binding.
- trait
- In C++ template metaprogramming, a mechanism to query properties of types. This often involves compiler-specific extensions or features.
- structured binding
- A C++17 language feature that allows deconstructing an object (like a tuple or struct) into individual variables.
- semantics.cc
- A GCC source file containing logic for semantic analysis of C++ code, including type checking and expression evaluation.
- pt.cc
- A GCC source file related to template substitution and expression handling in the C++ frontend.