X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=libiberty%2Fcp-demangle.c;h=d2d15e9b91aa83e85156b4340414766a8517bc89;hb=8e64f2a0d16624f14501c568f4bb2d7d79be9670;hp=98c64db552f8642eb328798d78125e2e62455237;hpb=f9b58c5ba68696e797030f26a469cc432cf20397;p=binutils-gdb.git diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 98c64db552f..d2d15e9b91a 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -302,6 +302,8 @@ struct d_print_info /* The current index into any template argument packs we are using for printing. */ int pack_index; + /* Number of d_print_flush calls so far. */ + unsigned long int flush_count; }; #ifdef CP_DEMANGLE_DEBUG @@ -1987,6 +1989,8 @@ cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT] = /* 29 */ { NL ("half"), NL ("half"), D_PRINT_FLOAT }, /* 30 */ { NL ("char16_t"), NL ("char16_t"), D_PRINT_DEFAULT }, /* 31 */ { NL ("char32_t"), NL ("char32_t"), D_PRINT_DEFAULT }, + /* 32 */ { NL ("decltype(nullptr)"), NL ("decltype(nullptr)"), + D_PRINT_DEFAULT }, }; CP_STATIC_IF_GLIBCPP_V3 @@ -2221,6 +2225,12 @@ cplus_demangle_type (struct d_info *di) ret = d_vector_type (di); break; + case 'n': + /* decltype(nullptr) */ + ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[32]); + di->expansion += ret->u.s_builtin.type->len; + break; + default: return NULL; } @@ -3277,6 +3287,7 @@ d_print_init (struct d_print_info *dpi, int options, dpi->last_char = '\0'; dpi->templates = NULL; dpi->modifiers = NULL; + dpi->flush_count = 0; dpi->callback = callback; dpi->opaque = opaque; @@ -3306,6 +3317,7 @@ d_print_flush (struct d_print_info *dpi) dpi->buf[dpi->len] = '\0'; dpi->callback (dpi->buf, dpi->len, dpi->opaque); dpi->len = 0; + dpi->flush_count++; } /* Append characters and buffers for printing. */ @@ -4039,12 +4051,18 @@ d_print_comp (struct d_print_info *dpi, if (d_right (dc) != NULL) { size_t len; + unsigned long int flush_count; + /* Make sure ", " isn't flushed by d_append_string, otherwise + dpi->len -= 2 wouldn't work. */ + if (dpi->len >= sizeof (dpi->buf) - 2) + d_print_flush (dpi); d_append_string (dpi, ", "); len = dpi->len; + flush_count = dpi->flush_count; d_print_comp (dpi, d_right (dc)); /* If that didn't print anything (which can happen with empty template argument packs), remove the comma and space. */ - if (dpi->len == len) + if (dpi->flush_count == flush_count && dpi->len == len) dpi->len -= 2; } return;