* c-exp.y (qualified_name): Call destructor_name_p with $1.type.
(classify_inner_name): Call cp_lookup_nested_type with
yylval.tsym.type.
* cp-namespace.c (cp_lookup_nested_type): New variable
saved_parent_type. Call CHECK_TYPEDEF for parent_type. Call
type_name_no_tag_or_error with saved_parent_type.
* dwarf2read.c (load_partial_dies): Read in any children of
DW_TAG_typedef with complaint in such case.
* gdbtypes.c (type_name_no_tag_or_error): New function.
* gdbtypes.h (type_name_no_tag_or_error): New prototype.
* valops.c (destructor_name_p): New comment for parameter type. Remove
type const. Make dname and cp const. Call type_name_no_tag_or_error.
* value.h (destructor_name_p): Remove type const.
+2011-05-06 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * c-exp.y (qualified_name): Call destructor_name_p with $1.type.
+ (classify_inner_name): Call cp_lookup_nested_type with
+ yylval.tsym.type.
+ * cp-namespace.c (cp_lookup_nested_type): New variable
+ saved_parent_type. Call CHECK_TYPEDEF for parent_type. Call
+ type_name_no_tag_or_error with saved_parent_type.
+ * dwarf2read.c (load_partial_dies): Read in any children of
+ DW_TAG_typedef with complaint in such case.
+ * gdbtypes.c (type_name_no_tag_or_error): New function.
+ * gdbtypes.h (type_name_no_tag_or_error): New prototype.
+ * valops.c (destructor_name_p): New comment for parameter type. Remove
+ type const. Make dname and cp const. Call type_name_no_tag_or_error.
+ * value.h (destructor_name_p): Remove type const.
+
2011-05-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* symtab.c (compare_symbol_name): New function.
tmp_token.ptr[tmp_token.length] = 0;
/* Check for valid destructor name. */
- destructor_name_p (tmp_token.ptr, type);
+ destructor_name_p (tmp_token.ptr, $1.type);
write_exp_elt_opcode (OP_SCOPE);
write_exp_elt_type (type);
write_exp_string (tmp_token);
return NAME;
copy = copy_name (yylval.tsym.stoken);
- new_type = cp_lookup_nested_type (type, copy, block);
+ new_type = cp_lookup_nested_type (yylval.tsym.type, copy, block);
if (new_type == NULL)
/* We know the caller won't expect us to update yylval. */
const char *nested_name,
const struct block *block)
{
+ /* type_name_no_tag_required provides better error reporting using the
+ original type. */
+ struct type *saved_parent_type = parent_type;
+
+ CHECK_TYPEDEF (parent_type);
+
switch (TYPE_CODE (parent_type))
{
case TYPE_CODE_STRUCT:
just like members of namespaces; in particular,
lookup_symbol_namespace works when looking them up. */
- const char *parent_name = TYPE_TAG_NAME (parent_type);
+ const char *parent_name = type_name_no_tag_or_error (saved_parent_type);
struct symbol *sym
= cp_lookup_symbol_in_namespace (parent_name, nested_name,
block, VAR_DOMAIN);
if (parent_die == NULL
&& part_die->has_specification == 0
&& part_die->is_declaration == 0
- && (part_die->tag == DW_TAG_typedef
+ && ((part_die->tag == DW_TAG_typedef && !part_die->has_children)
|| part_die->tag == DW_TAG_base_type
|| part_die->tag == DW_TAG_subrange_type))
{
continue;
}
+ /* The exception for DW_TAG_typedef with has_children above is
+ a workaround of GCC PR debug/47510. In the case of this complaint
+ type_name_no_tag_or_error will error on such types later.
+
+ GDB skipped children of DW_TAG_typedef by the shortcut above and then
+ it could not find the child DIEs referenced later, this is checked
+ above. In correct DWARF DW_TAG_typedef should have no children. */
+
+ if (part_die->tag == DW_TAG_typedef && part_die->has_children)
+ complaint (&symfile_complaints,
+ _("DW_TAG_typedef has childen - GCC PR debug/47510 bug "
+ "- DIE at 0x%x [in module %s]"),
+ part_die->offset, cu->objfile->name);
+
/* If we're at the second level, and we're an enumerator, and
our parent has no specification (meaning possibly lives in a
namespace elsewhere), then we can add the partial symbol now
return TYPE_NAME (type);
}
+/* A wrapper of type_name_no_tag which calls error if the type is anonymous.
+ Since GCC PR debug/47510 DWARF provides associated information to detect the
+ anonymous class linkage name from its typedef.
+
+ Parameter TYPE should not yet have CHECK_TYPEDEF applied, this function will
+ apply it itself. */
+
+const char *
+type_name_no_tag_or_error (struct type *type)
+{
+ struct type *saved_type = type;
+ const char *name;
+ struct objfile *objfile;
+
+ CHECK_TYPEDEF (type);
+
+ name = type_name_no_tag (type);
+ if (name != NULL)
+ return name;
+
+ name = type_name_no_tag (saved_type);
+ objfile = TYPE_OBJFILE (saved_type);
+ error (_("Invalid anonymous type %s [in module %s], GCC PR debug/47510 bug?"),
+ name ? name : "<anonymous>", objfile ? objfile->name : "<arch>");
+}
+
/* Lookup a typedef or primitive type named NAME, visible in lexical
block BLOCK. If NOERR is nonzero, return zero if NAME is not
suitably defined. */
extern char *type_name_no_tag (const struct type *);
+extern const char *type_name_no_tag_or_error (struct type *type);
+
extern struct type *lookup_struct_elt_type (struct type *, char *, int);
extern struct type *make_pointer_type (struct type *, struct type **);
/* C++: return 1 is NAME is a legitimate name for the destructor of
type TYPE. If TYPE does not have a destructor, or if NAME is
- inappropriate for TYPE, an error is signaled. */
+ inappropriate for TYPE, an error is signaled. Parameter TYPE should not yet
+ have CHECK_TYPEDEF applied, this function will apply it itself. */
+
int
-destructor_name_p (const char *name, const struct type *type)
+destructor_name_p (const char *name, struct type *type)
{
if (name[0] == '~')
{
- char *dname = type_name_no_tag (type);
- char *cp = strchr (dname, '<');
+ const char *dname = type_name_no_tag_or_error (type);
+ const char *cp = strchr (dname, '<');
unsigned int len;
/* Do not compare the template part for template classes. */
extern int unop_user_defined_p (enum exp_opcode op, struct value *arg1);
-extern int destructor_name_p (const char *name, const struct type *type);
+extern int destructor_name_p (const char *name, struct type *type);
extern void value_incref (struct value *val);