+2010-09-30 Tom Tromey <tromey@redhat.com>
+
+ * completer.c (count_struct_fields): Handle anonymous structs and
+ unions.
+ (add_struct_fields): Likewise.
+
2010-09-30 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix printing parameters of inlined functions.
if (i < TYPE_N_BASECLASSES (type))
result += count_struct_fields (TYPE_BASECLASS (type, i));
else if (TYPE_FIELD_NAME (type, i))
- ++result;
+ {
+ if (TYPE_FIELD_NAME (type, i)[0] != '\0')
+ ++result;
+ else if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_UNION)
+ {
+ /* Recurse into anonymous unions. */
+ result += count_struct_fields (TYPE_FIELD_TYPE (type, i));
+ }
+ }
}
for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i)
if (i < TYPE_N_BASECLASSES (type))
add_struct_fields (TYPE_BASECLASS (type, i), nextp, output,
fieldname, namelen);
- else if (TYPE_FIELD_NAME (type, i)
- && ! strncmp (TYPE_FIELD_NAME (type, i), fieldname, namelen))
+ else if (TYPE_FIELD_NAME (type, i))
{
- output[*nextp] = xstrdup (TYPE_FIELD_NAME (type, i));
- ++*nextp;
+ if (TYPE_FIELD_NAME (type, i)[0] != '\0')
+ {
+ if (! strncmp (TYPE_FIELD_NAME (type, i), fieldname, namelen))
+ {
+ output[*nextp] = xstrdup (TYPE_FIELD_NAME (type, i));
+ ++*nextp;
+ }
+ }
+ else if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_UNION)
+ {
+ /* Recurse into anonymous unions. */
+ add_struct_fields (TYPE_FIELD_TYPE (type, i), nextp, output,
+ fieldname, namelen);
+ }
}
}
timeout { fail "(timeout) complete 'p &values\[0\] -> a' 2" }
}
+gdb_test "complete p &values\[0\]->z" \
+ "p &values.0.->z_field" \
+ "copmletion of field in anonymous union"
+
# The following tests used to simply try to complete `${objdir}/file',
# and so on. The problem is that ${objdir} can be very long; the
# completed filename may be more than eighty characters wide. When