The previous fix only worked for C, for C++ we need to add more information to the underlying type so that finish_class_member_access_expr accepts it.
This patch makes gcc.target/arm/mve/intrinsics/pr118332.c pass in C++ mode. gcc/ChangeLog: PR target/118332 * config/arm/arm-mve-builtins.cc (wrap_type_in_struct): Handle C++ case. --- gcc/config/arm/arm-mve-builtins.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gcc/config/arm/arm-mve-builtins.cc b/gcc/config/arm/arm-mve-builtins.cc index 846cd773c0b..2cf81853cfa 100644 --- a/gcc/config/arm/arm-mve-builtins.cc +++ b/gcc/config/arm/arm-mve-builtins.cc @@ -457,6 +457,22 @@ wrap_type_in_struct (tree field_type) tree field = build_decl (input_location, FIELD_DECL, get_identifier ("val"), field_type); tree struct_type = lang_hooks.types.make_type (RECORD_TYPE); + + /* In C++ we need more info to comply with CLASS_TYPE_P and lookup_member in + finish_class_member_access_expr. */ + if (lang_GNU_CXX ()) + { + /* Equivalent to SET_CLASS_TYPE_P (struct_type, 1); but SET_CLASS_TYPE_P + is not available here. */ + struct_type->type_common.lang_flag_5 = 1; + + /* Extracted from xref_basetypes. */ + tree binfo = make_tree_binfo (0); + TYPE_BINFO (struct_type) = binfo; + BINFO_OFFSET (binfo) = size_zero_node; + BINFO_TYPE (binfo) = struct_type; + } + DECL_FIELD_CONTEXT (field) = struct_type; TYPE_FIELDS (struct_type) = field; layout_type (struct_type); -- 2.34.1