On 12/04/2017 07:00 PM, Jakub Jelinek wrote:
@@ -1291,7 +1291,56 @@ write_unqualified_name (tree decl) { found = true; gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl)); - write_source_name (DECL_ASSEMBLER_NAME (decl)); + if (VAR_P (decl) + && DECL_DECOMPOSITION_P (decl) + && DECL_NAME (decl) == NULL_TREE + && DECL_NAMESPACE_SCOPE_P (decl)) + { + const char *p = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + const char *end = p + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)); + bool nested = false; + /* The list of identifiers is likely gone at this point, so find the + DC <source-name>+ E part in the mangled name. */ + if (!strncmp (p, "_Z", 2)) + { + p += 2; + if (!strncmp (p, "St", 2)) + p += 2; + else if (*p == 'N') + { + nested = true; + ++p; + while (ISDIGIT (p[0])) + { + char *e; + long num = strtol (p, &e, 10); + if (num >= 1 && num < end - e) + p = e + num; + else + break; + } + } + if (strncmp (p, "DC", 2)) + p = NULL; + if (nested) + { + if (end[-1] != 'E') + p = NULL; + else + --end; + } + if (end[-1] != 'E') + p = NULL; + } + else + p = NULL; + if (p == NULL) + write_source_name (DECL_ASSEMBLER_NAME (decl)); + else + write_chars (p, end - p); + } + else + write_source_name (DECL_ASSEMBLER_NAME (decl)); }
Please break (most of) this out into a separate function. OK with that change.
Jason