From 72c5ecc2fffe43146eaf54284cf9626b7f76cb78 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 19 Aug 2009 18:19:53 -0700 Subject: [PATCH] PR10538: Give a file:line hint for anonymous types When we list the possible members for an anonymous struct/union, the user may want to go look at the source for the type. That's hard without a type name, so we now list the decl file:line for them. * dwflpp.cxx (dwflpp::translate_components): List file:line for anon. --- dwflpp.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dwflpp.cxx b/dwflpp.cxx index dce19f219..780a3510b 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -1762,15 +1762,26 @@ dwflpp::translate_components(struct obstack *pool, vector locs; if (!find_struct_member(c, &parentdie, die, locs)) { + /* Add a file:line hint for anonymous types */ + string source; + if (!dwarf_hasattr_integrate(&parentdie, DW_AT_name)) + { + int line; + const char *file = dwarf_decl_file(&parentdie); + if (file && dwarf_decl_line(&parentdie, &line) == 0) + source = " (" + string(file) + ":" + + lex_cast(line) + ")"; + } + string alternatives; stringstream members; print_members(&parentdie, members); if (members.str().size() != 0) - alternatives = " (alternatives:" + members.str(); + alternatives = " (alternatives:" + members.str() + ")"; throw semantic_error("unable to find member '" + c.member + "' for " + dwarf_type_name(&parentdie) - + alternatives, + + source + alternatives, c.tok); } -- 2.43.5