From e3a5d5207584e31543d1812f76e288a08b8703ea Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Sat, 31 Dec 2022 12:03:16 +0000 Subject: sync libiberty sources with gcc mainline --- libiberty/ChangeLog | 315 +++++++++++++++++++++++--- libiberty/README | 2 +- libiberty/_doprnt.c | 1 - libiberty/configure | 7 +- libiberty/cp-demangle.c | 406 +++++++++++++++++++++++++++------- libiberty/cp-demangle.h | 2 +- libiberty/functions.texi | 2 +- libiberty/testsuite/demangle-expected | 93 +++++++- 8 files changed, 717 insertions(+), 111 deletions(-) (limited to 'libiberty') diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 43eae83c229..0e2289d81b7 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,6 +1,271 @@ -2022-07-08 Nick Clifton +2022-11-23 Marek Polacek - * 2.39 branch created. + Revert: + 2022-11-23 Marek Polacek + + * configure.ac: Also set shared when enable_host_pie. + * configure: Regenerate. + +2022-11-23 Marek Polacek + + * configure.ac: Also set shared when enable_host_pie. + * configure: Regenerate. + +2022-11-15 Nathan Sidwell + + * cp-demangle.c (struct d_print_info): Rename is_lambda_arg to + lambda_tpl_parms. Augment semantics. + (d_make_comp): Add checks for new components. + (d_template_parm, d_template_head): New. + (d_lambda): Add templated lambda support. + (d_print_init): Adjust. + (d_print_lambda_parm_name): New. + (d_print_comp_inner): Support templated lambdas, + * testsuite/demangle-expected: Add testcases. + +2022-11-14 Martin Liska + + Revert: + 2022-11-14 Martin Liska + + * doc/bsd.rst: New file. + * doc/conf.py: New file. + * doc/copyright.rst: New file. + * doc/extensions.rst: New file. + * doc/function-variable-and-macro-listing.rst: New file. + * doc/index.rst: New file. + * doc/indices-and-tables.rst: New file. + * doc/introduction.rst: New file. + * doc/lesser-general-public-license-2.1.rst: New file. + * doc/overview.rst: New file. + * doc/replacement-functions.rst: New file. + * doc/supplemental-functions.rst: New file. + * doc/using.rst: New file. + +2022-11-14 Martin Liska + + Revert: + 2022-11-14 Martin Liska + + * Makefile.in: Support Sphinx based documentation. + +2022-11-14 Martin Liska + + Revert: + 2022-11-14 Martin Liska + + * at-file.texi: Removed. + * copying-lib.texi: Removed. + * functions.texi: Removed. + * libiberty.texi: Removed. + * obstacks.texi: Removed. + +2022-11-14 Martin Liska + + Revert: + 2022-11-14 Martin Liska + + * Makefile.in: Support --with-sphinx-build. + * configure.ac: Likewise. + * configure: Regenerate. + +2022-11-14 Martin Liska + + Revert: + 2022-11-14 Martin Liska + + * doc/bsd.rst: + Add trailing newline. + * doc/copyright.rst: + Add trailing newline. + * doc/extensions.rst: + Add trailing newline. + * doc/function-variable-and-macro-listing.rst: + Add trailing newline. + * doc/index.rst: + Add trailing newline. + * doc/indices-and-tables.rst: + Add trailing newline. + * doc/introduction.rst: + Add trailing newline. + * doc/lesser-general-public-license-2.1.rst: + Add trailing newline. + * doc/overview.rst: + Add trailing newline. + * doc/replacement-functions.rst: + Add trailing newline. + * doc/supplemental-functions.rst: + Add trailing newline. + * doc/using.rst: + Add trailing newline. + +2022-11-14 Martin Liska + + Revert: + 2022-11-14 Martin Liska + + * doc/conf.py: Add newline at last line. + +2022-11-14 Martin Liska + + Revert: + 2022-11-14 Martin Liska + + PR other/107620 + * configure: Regenerate. + * configure.ac: Always set sphinx-build. + +2022-11-13 Martin Liska + + PR other/107620 + * configure: Regenerate. + * configure.ac: Always set sphinx-build. + +2022-11-10 Martin Liska + + * doc/conf.py: Add newline at last line. + +2022-11-09 Martin Liska + + * doc/bsd.rst: + Add trailing newline. + * doc/copyright.rst: + Add trailing newline. + * doc/extensions.rst: + Add trailing newline. + * doc/function-variable-and-macro-listing.rst: + Add trailing newline. + * doc/index.rst: + Add trailing newline. + * doc/indices-and-tables.rst: + Add trailing newline. + * doc/introduction.rst: + Add trailing newline. + * doc/lesser-general-public-license-2.1.rst: + Add trailing newline. + * doc/overview.rst: + Add trailing newline. + * doc/replacement-functions.rst: + Add trailing newline. + * doc/supplemental-functions.rst: + Add trailing newline. + * doc/using.rst: + Add trailing newline. + +2022-11-09 Martin Liska + + * Makefile.in: Support --with-sphinx-build. + * configure.ac: Likewise. + * configure: Regenerate. + +2022-11-09 Martin Liska + + * at-file.texi: Removed. + * copying-lib.texi: Removed. + * functions.texi: Removed. + * libiberty.texi: Removed. + * obstacks.texi: Removed. + +2022-11-09 Martin Liska + + * Makefile.in: Support Sphinx based documentation. + +2022-11-09 Martin Liska + + * doc/bsd.rst: New file. + * doc/conf.py: New file. + * doc/copyright.rst: New file. + * doc/extensions.rst: New file. + * doc/function-variable-and-macro-listing.rst: New file. + * doc/index.rst: New file. + * doc/indices-and-tables.rst: New file. + * doc/introduction.rst: New file. + * doc/lesser-general-public-license-2.1.rst: New file. + * doc/overview.rst: New file. + * doc/replacement-functions.rst: New file. + * doc/supplemental-functions.rst: New file. + * doc/using.rst: New file. + +2022-10-18 Florian Weimer + + * acinclude.m4 (ac_cv_func_strncmp_works): Add missing + int return type and parameter list to the definition of main. + Include and for prototypes. + (ac_cv_c_stack_direction): Add missing + int return type and parameter list to the definitions of + main, find_stack_direction. Include for exit + prototype. + * configure: Regenerate. + +2022-10-14 Jakub Jelinek + + * cp-demangle.h (D_BUILTIN_TYPE_COUNT): Increment. + * cp-demangle.c (cplus_demangle_builtin_types): Add std::bfloat16_t + entry. + (cplus_demangle_type): Demangle DF16b. + * testsuite/demangle-expected (_Z3xxxDF16b): New test. + +2022-10-11 Nathan Sidwell + + * cp-demangle.c (d_prefix): 'M' components are not + (re-)added to the substitution table. + * testsuite/demangle-expected: Add tests. + +2022-10-07 Nathan Sidwell + + * cp-demangle.c (d_print_comp_inner): Allow parameter packs + in a lambda signature. + * testsuite/demangle-expected: Add tests. + +2022-09-27 Jakub Jelinek + + PR c++/106652 + PR c++/85518 + * cp-demangle.c (d_dump): Handle + DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE. Don't handle + DEMANGLE_COMPONENT_FIXED_TYPE. + (d_make_extended_builtin_type): New function. + (cplus_demangle_builtin_types): Add _Float entry. + (cplus_demangle_type): For DF demangle it as _Float or + _Floatx rather than fixed point which conflicts with it. + (d_count_templates_scopes): Handle + DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE. Just break; for + DEMANGLE_COMPONENT_FIXED_TYPE. + (d_find_pack): Handle DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE. + Don't handle DEMANGLE_COMPONENT_FIXED_TYPE. + (d_print_comp_inner): Likewise. + * cp-demangle.h (D_BUILTIN_TYPE_COUNT): Bump. + * testsuite/demangle-expected: Replace _Z3xxxDFyuVb test + with _Z3xxxDF16_DF32_DF64_DF128_CDF16_Vb. Add + _Z3xxxDF32xDF64xDF128xCDF32xVb test. + +2022-09-22 Jonathan Wakely + + * README: Replace gcc-bugs email address with Bugzilla URL. + +2022-08-25 Martin Liska + + * configure: Regenerate. + +2022-07-22 Martin Liska + + PR other/106370 + * _doprnt.c: Remove continue as last stmt + in a loop. + +2022-07-14 Martin Liska + + * functions.texi: Replace strtoul with strtoull. + +2022-07-04 Nick Clifton + + * rust-demangle.c (demangle_const): Add a missing goto pass_return + at the end of the function. + +2022-07-04 Nick Clifton + + * rust-demangle.c (demangle_path_maybe_open_generics): Add + recursion limit. 2022-07-01 Nick Clifton @@ -1488,7 +1753,7 @@ 2016-06-12 Brooks Moses * cp-demangle.c (cplus_demangle_print_callback): Avoid zero-length - VLAs. + VLAs. 2016-05-31 Alan Modra @@ -3065,8 +3330,8 @@ 2009-08-23 H.J. Lu - PR ld/10536 - * Makefile.in (install-html-recursive): Removed. + PR ld/10536 + * Makefile.in (install-html-recursive): Removed. 2009-08-22 Ralf Wildenhues @@ -7500,7 +7765,7 @@ Sun Nov 28 00:59:39 1999 Philippe De Muyter * strtoul.c, strtol.c, random.c: Remove advertising clause from BSD license, pursuant with - ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change + ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change Wed Nov 10 09:42:39 1999 Jeffrey A Law (law@cygnus.com) @@ -9884,12 +10149,12 @@ Sun Feb 27 21:50:11 1994 Jim Kingdon (kingdon@deneb.cygnus.com) Thu Feb 24 11:51:12 1994 David J. Mackenzie (djm@rtl.cygnus.com) * getopt.c: Remove #ifdef GETOPT_COMPAT and #if 0 code. - (_getopt_initialize): New function, broken out of _getopt_internal. - (_getopt_internal): - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. + (_getopt_initialize): New function, broken out of _getopt_internal. + (_getopt_internal): + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. Thu Feb 10 14:44:16 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu) @@ -10109,8 +10374,8 @@ Fri Oct 22 07:53:15 1993 Jim Kingdon (kingdon@lioth.cygnus.com) Tue Oct 19 17:12:01 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) * Makefile.in (lneeded-list): ensure that object file names are - not duplicated, as multiple instances of the same object file in - a library causes problems on some machines + not duplicated, as multiple instances of the same object file in + a library causes problems on some machines Mon Oct 18 21:59:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com) @@ -10523,10 +10788,10 @@ Wed Sep 9 12:41:48 1992 Ian Lance Taylor (ian@cygnus.com) Thu Sep 3 13:29:39 1992 K. Richard Pixley (rich@sendai.cygnus.com) * cplus-dem.c: (demangle_prefix): reduction in strength of strstr - as a time optimization. + as a time optimization. * cplus-dem.c (cplus_demangle): remove strpbrk test. Appears to - be more expensive than simply demangling. + be more expensive than simply demangling. * cplus-dem.c (cplus_match): new function. @@ -10622,7 +10887,7 @@ Wed Jun 17 18:13:58 1992 Per Bothner (bothner@rtl.cygnus.com) Tue Jun 16 16:11:59 1992 K. Richard Pixley (rich@rtl.cygnus.com) * getopt.c, getopt1.c: merged largely gratuitous, mostly - whitespace diffs from other prep distributions. + whitespace diffs from other prep distributions. Mon Jun 15 12:25:46 1992 Fred Fish (fnf@cygnus.com) @@ -10712,7 +10977,7 @@ Mon Apr 20 20:49:32 1992 K. Richard Pixley (rich@cygnus.com) * Makefile.in: do not print recursion line. * Makefile.in: allow CFLAGS to be passed in from command line. - Removed MINUS_G. Default CFLAGS to -g. + Removed MINUS_G. Default CFLAGS to -g. Mon Apr 20 12:57:46 1992 Per Bothner (bothner@rtl.cygnus.com) @@ -10783,8 +11048,8 @@ Thu Feb 27 22:19:39 1992 Per Bothner (bothner@cygnus.com) Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com) * Makefile.in, configure.in: removed traces of namesubdir, - -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced - copyrights to '92, changed some from Cygnus to FSF. + -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced + copyrights to '92, changed some from Cygnus to FSF. Sat Feb 22 01:09:21 1992 Stu Grossman (grossman at cygnus.com) @@ -10869,17 +11134,17 @@ Tue Dec 10 04:14:49 1991 K. Richard Pixley (rich at rtl.cygnus.com) Fri Dec 6 23:26:45 1991 K. Richard Pixley (rich at rtl.cygnus.com) * Makefile.in: remove spaces following hyphens because bsd make - can't cope. added standards.text support. install using - INSTALL_DATA. + can't cope. added standards.text support. install using + INSTALL_DATA. * configure.in: remove commontargets as it is no longer a - recognized hook. + recognized hook. Thu Dec 5 22:46:46 1991 K. Richard Pixley (rich at rtl.cygnus.com) * Makefile.in: idestdir and ddestdir go away. Added copyrights - and shift gpl to v2. Added ChangeLog if it didn't exist. docdir - and mandir now keyed off datadir by default. + and shift gpl to v2. Added ChangeLog if it didn't exist. docdir + and mandir now keyed off datadir by default. Fri Nov 22 19:15:29 1991 John Gilmore (gnu at cygnus.com) diff --git a/libiberty/README b/libiberty/README index 9f1cc979e49..e7ffb17c192 100644 --- a/libiberty/README +++ b/libiberty/README @@ -15,7 +15,7 @@ The library must be configured from the top source directory. Don't try to run configure in this directory. Follow the configuration instructions in ../README. -Please report bugs to "gcc-bugs@gcc.gnu.org" and send fixes to +Please report bugs to https://gcc.gnu.org/bugzilla/ and send fixes to "gcc-patches@gcc.gnu.org". Thank you. ADDING A NEW FILE diff --git a/libiberty/_doprnt.c b/libiberty/_doprnt.c index cebaa16056b..c7232d858c6 100644 --- a/libiberty/_doprnt.c +++ b/libiberty/_doprnt.c @@ -55,7 +55,6 @@ Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ putc(CHAR, stream); \ ptr++; \ total_printed++; \ - continue; \ } while (0) #define PRINT_TYPE(TYPE) \ diff --git a/libiberty/configure b/libiberty/configure index 451af4978e7..79ef15312e2 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -5349,6 +5349,9 @@ case "${host}" in # sets the default TLS model and affects inlining. PICFLAG=-fPIC ;; + loongarch*-*-*) + PICFLAG=-fpic + ;; mips-sgi-irix6*) # PIC is the default. ;; @@ -5365,7 +5368,9 @@ case "${host}" in sh-*-linux* | sh[2346lbe]*-*-linux*) PICFLAG=-fpic ;; - sh*-*-netbsd*) + # FIXME: Simplify to sh*-*-netbsd*? + sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \ + sh64-*-netbsd* | sh64l*-*-netbsd*) PICFLAG=-fpic ;; # Default to -fPIC unless specified otherwise. diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index d06d80d1fee..ad533f6085e 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -347,9 +347,9 @@ struct d_print_info /* Number of times d_print_comp was recursively called. Should not be bigger than MAX_RECURSION_COUNT. */ int recursion; - /* Non-zero if we're printing a lambda argument. A template - parameter reference actually means 'auto'. */ - int is_lambda_arg; + /* 1 more than the number of explicit template parms of a lambda. Template + parm references >= are actually 'auto'. */ + int lambda_tpl_parms; /* The current index into any template argument packs we are using for printing, or -1 to print the whole pack. */ int pack_index; @@ -491,6 +491,10 @@ static struct demangle_component *d_local_name (struct d_info *); static int d_discriminator (struct d_info *); +static struct demangle_component *d_template_parm (struct d_info *, int *bad); + +static struct demangle_component *d_template_head (struct d_info *, int *bad); + static struct demangle_component *d_lambda (struct d_info *); static struct demangle_component *d_unnamed_type (struct d_info *); @@ -648,6 +652,13 @@ d_dump (struct demangle_component *dc, int indent) case DEMANGLE_COMPONENT_BUILTIN_TYPE: printf ("builtin type %s\n", dc->u.s_builtin.type->name); return; + case DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE: + { + char suffix[2] = { dc->u.s_extended_builtin.type->suffix, 0 }; + printf ("builtin type %s%d%s\n", dc->u.s_extended_builtin.type->name, + dc->u.s_extended_builtin.type->arg, suffix); + } + return; case DEMANGLE_COMPONENT_OPERATOR: printf ("operator %s\n", dc->u.s_operator.op->name); return; @@ -771,11 +782,6 @@ d_dump (struct demangle_component *dc, int indent) case DEMANGLE_COMPONENT_PTRMEM_TYPE: printf ("pointer to member type\n"); break; - case DEMANGLE_COMPONENT_FIXED_TYPE: - printf ("fixed-point type, accum? %d, sat? %d\n", - dc->u.s_fixed.accum, dc->u.s_fixed.sat); - d_dump (dc->u.s_fixed.length, indent + 2); - break; case DEMANGLE_COMPONENT_ARGLIST: printf ("argument list\n"); break; @@ -1026,6 +1032,10 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_TPARM_OBJ: case DEMANGLE_COMPONENT_STRUCTURED_BINDING: case DEMANGLE_COMPONENT_MODULE_INIT: + case DEMANGLE_COMPONENT_TEMPLATE_HEAD: + case DEMANGLE_COMPONENT_TEMPLATE_NON_TYPE_PARM: + case DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM: + case DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM: if (left == NULL) return NULL; break; @@ -1048,6 +1058,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_CONST: case DEMANGLE_COMPONENT_ARGLIST: case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: + case DEMANGLE_COMPONENT_TEMPLATE_TYPE_PARM: FNQUAL_COMPONENT_CASE: break; @@ -1109,6 +1120,28 @@ d_make_builtin_type (struct d_info *di, return p; } +/* Add a new extended builtin type component. */ + +static struct demangle_component * +d_make_extended_builtin_type (struct d_info *di, + const struct demangle_builtin_type_info *type, + short arg, char suffix) +{ + struct demangle_component *p; + + if (type == NULL) + return NULL; + p = d_make_empty (di); + if (p != NULL) + { + p->type = DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE; + p->u.s_extended_builtin.type = type; + p->u.s_extended_builtin.arg = arg; + p->u.s_extended_builtin.suffix = suffix; + } + return p; +} + /* Add a new operator component. */ static struct demangle_component * @@ -1585,12 +1618,10 @@ d_prefix (struct d_info *di, int substable) } else if (peek == 'M') { - /* Initializer scope for a lambda. We don't need to represent - this; the normal code will just treat the variable as a type - scope, which gives appropriate output. */ - if (ret == NULL) - return NULL; + /* Initializer scope for a lambda. We already added it as a + substitution candidate, don't do that again. */ d_advance (di, 1); + continue; } else { @@ -2464,6 +2495,8 @@ cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT] = /* 32 */ { NL ("char32_t"), NL ("char32_t"), D_PRINT_DEFAULT }, /* 33 */ { NL ("decltype(nullptr)"), NL ("decltype(nullptr)"), D_PRINT_DEFAULT }, + /* 34 */ { NL ("_Float"), NL ("_Float"), D_PRINT_FLOAT }, + /* 35 */ { NL ("std::bfloat16_t"), NL ("std::bfloat16_t"), D_PRINT_FLOAT }, }; CP_STATIC_IF_GLIBCPP_V3 @@ -2727,19 +2760,37 @@ cplus_demangle_type (struct d_info *di) break; case 'F': - /* Fixed point types. DF */ - ret = d_make_empty (di); - ret->type = DEMANGLE_COMPONENT_FIXED_TYPE; - if ((ret->u.s_fixed.accum = IS_DIGIT (d_peek_char (di)))) - /* For demangling we don't care about the bits. */ - d_number (di); - ret->u.s_fixed.length = cplus_demangle_type (di); - if (ret->u.s_fixed.length == NULL) - return NULL; - d_number (di); - peek = d_next_char (di); - ret->u.s_fixed.sat = (peek == 's'); - break; + /* DF_ - _Float. + DFx - _Floatx + DF16b - std::bfloat16_t. */ + { + int arg = d_number (di); + char buf[12]; + char suffix = 0; + if (d_peek_char (di) == 'b') + { + if (arg != 16) + return NULL; + d_advance (di, 1); + ret = d_make_builtin_type (di, + &cplus_demangle_builtin_types[35]); + di->expansion += ret->u.s_builtin.type->len; + break; + } + if (d_peek_char (di) == 'x') + suffix = 'x'; + if (!suffix && d_peek_char (di) != '_') + return NULL; + ret + = d_make_extended_builtin_type (di, + &cplus_demangle_builtin_types[34], + arg, suffix); + d_advance (di, 1); + sprintf (buf, "%d", arg); + di->expansion += ret->u.s_extended_builtin.type->len + + strlen (buf) + (suffix != 0); + break; + } case 'v': ret = d_vector_type (di); @@ -3835,32 +3886,120 @@ d_discriminator (struct d_info *di) return 1; } -/* ::= Ul E [ ] _ */ +/* ::= Ty + ::= Tn + ::= Tt E + ::= Tp */ static struct demangle_component * -d_lambda (struct d_info *di) +d_template_parm (struct d_info *di, int *bad) { - struct demangle_component *tl; - struct demangle_component *ret; - int num; + if (d_peek_char (di) != 'T') + return NULL; + struct demangle_component *op; + enum demangle_component_type kind; + switch (d_peek_next_char (di)) + { + default: + return NULL; + + case 'p': /* Pack */ + d_advance (di, 2); + op = d_template_parm (di, bad); + kind = DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM; + if (!op) + { + *bad = 1; + return NULL; + } + break; + + case 'y': /* Typename */ + d_advance (di, 2); + op = NULL; + kind = DEMANGLE_COMPONENT_TEMPLATE_TYPE_PARM; + break; + + case 'n': /* Non-Type */ + d_advance (di, 2); + op = cplus_demangle_type (di); + kind = DEMANGLE_COMPONENT_TEMPLATE_NON_TYPE_PARM; + if (!op) + { + *bad = 1; + return NULL; + } + break; + + case 't': /* Template */ + d_advance (di, 2); + op = d_template_head (di, bad); + kind = DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM; + if (!op || !d_check_char (di, 'E')) + { + *bad = 1; + return NULL; + } + } + + return d_make_comp (di, kind, op, NULL); +} + +/* ::= ? */ + +static struct demangle_component * +d_template_head (struct d_info *di, int *bad) +{ + struct demangle_component *res = NULL, **slot = &res; + struct demangle_component *op; + + while ((op = d_template_parm (di, bad))) + { + *slot = op; + slot = &d_right (op); + } + + /* Wrap it in a template head, to make concatenating with any parm list, and + printing simpler. */ + if (res) + res = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE_HEAD, res, NULL); + + return res; +} + +/* ::= Ul ? E [ ] _ */ + +static struct demangle_component * +d_lambda (struct d_info *di) +{ if (! d_check_char (di, 'U')) return NULL; if (! d_check_char (di, 'l')) return NULL; - tl = d_parmlist (di); + int bad = 0; + struct demangle_component *head = d_template_head (di, &bad); + if (bad) + return NULL; + + struct demangle_component *tl = d_parmlist (di); if (tl == NULL) return NULL; + if (head) + { + d_right (head) = tl; + tl = head; + } if (! d_check_char (di, 'E')) return NULL; - num = d_compact_number (di); + int num = d_compact_number (di); if (num < 0) return NULL; - ret = d_make_empty (di); + struct demangle_component *ret = d_make_empty (di); if (ret) { ret->type = DEMANGLE_COMPONENT_LAMBDA; @@ -4202,6 +4341,7 @@ d_count_templates_scopes (struct d_print_info *dpi, case DEMANGLE_COMPONENT_FUNCTION_PARAM: case DEMANGLE_COMPONENT_SUB_STD: case DEMANGLE_COMPONENT_BUILTIN_TYPE: + case DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE: case DEMANGLE_COMPONENT_OPERATOR: case DEMANGLE_COMPONENT_CHARACTER: case DEMANGLE_COMPONENT_NUMBER: @@ -4210,6 +4350,12 @@ d_count_templates_scopes (struct d_print_info *dpi, case DEMANGLE_COMPONENT_MODULE_NAME: case DEMANGLE_COMPONENT_MODULE_PARTITION: case DEMANGLE_COMPONENT_MODULE_INIT: + case DEMANGLE_COMPONENT_FIXED_TYPE: + case DEMANGLE_COMPONENT_TEMPLATE_HEAD: + case DEMANGLE_COMPONENT_TEMPLATE_TYPE_PARM: + case DEMANGLE_COMPONENT_TEMPLATE_NON_TYPE_PARM: + case DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM: + case DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM: break; case DEMANGLE_COMPONENT_TEMPLATE: @@ -4309,10 +4455,6 @@ d_count_templates_scopes (struct d_print_info *dpi, d_count_templates_scopes (dpi, dc->u.s_extended_operator.name); break; - case DEMANGLE_COMPONENT_FIXED_TYPE: - d_count_templates_scopes (dpi, dc->u.s_fixed.length); - break; - case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: case DEMANGLE_COMPONENT_MODULE_ENTITY: @@ -4344,7 +4486,7 @@ d_print_init (struct d_print_info *dpi, demangle_callbackref callback, dpi->demangle_failure = 0; dpi->recursion = 0; - dpi->is_lambda_arg = 0; + dpi->lambda_tpl_parms = 0; dpi->component_stack = NULL; @@ -4580,11 +4722,11 @@ d_find_pack (struct d_print_info *dpi, case DEMANGLE_COMPONENT_TAGGED_NAME: case DEMANGLE_COMPONENT_OPERATOR: case DEMANGLE_COMPONENT_BUILTIN_TYPE: + case DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE: case DEMANGLE_COMPONENT_SUB_STD: case DEMANGLE_COMPONENT_CHARACTER: case DEMANGLE_COMPONENT_FUNCTION_PARAM: case DEMANGLE_COMPONENT_UNNAMED_TYPE: - case DEMANGLE_COMPONENT_FIXED_TYPE: case DEMANGLE_COMPONENT_DEFAULT_ARG: case DEMANGLE_COMPONENT_NUMBER: return NULL; @@ -4841,6 +4983,33 @@ d_maybe_print_designated_init (struct d_print_info *dpi, int options, return 1; } +static void +d_print_lambda_parm_name (struct d_print_info *dpi, int type, unsigned index) +{ + const char *str; + switch (type) + { + default: + dpi->demangle_failure = 1; + str = ""; + break; + + case DEMANGLE_COMPONENT_TEMPLATE_TYPE_PARM: + str = "$T"; + break; + + case DEMANGLE_COMPONENT_TEMPLATE_NON_TYPE_PARM: + str = "$N"; + break; + + case DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM: + str = "$TT"; + break; + } + d_append_string (dpi, str); + d_append_num (dpi, index); +} + /* Subroutine to handle components. */ static void @@ -5095,7 +5264,21 @@ d_print_comp_inner (struct d_print_info *dpi, int options, } case DEMANGLE_COMPONENT_TEMPLATE_PARAM: - if (dpi->is_lambda_arg) + if (dpi->lambda_tpl_parms > dc->u.s_number.number + 1) + { + const struct demangle_component *a + = d_left (dpi->templates->template_decl); + unsigned c; + for (c = dc->u.s_number.number; a && c; c--) + a = d_right (a); + if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM) + a = d_left (a); + if (!a) + dpi->demangle_failure = 1; + else + d_print_lambda_parm_name (dpi, a->type, dc->u.s_number.number); + } + else if (dpi->lambda_tpl_parms) { /* Show the template parm index, as that's how g++ displays these, and future proofs us against potential @@ -5276,7 +5459,7 @@ d_print_comp_inner (struct d_print_info *dpi, int options, { /* Handle reference smashing: & + && = &. */ struct demangle_component *sub = d_left (dc); - if (!dpi->is_lambda_arg + if (!dpi->lambda_tpl_parms && sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) { struct d_saved_scope *scope = d_get_saved_scope (dpi, sub); @@ -5387,6 +5570,14 @@ d_print_comp_inner (struct d_print_info *dpi, int options, dc->u.s_builtin.type->java_len); return; + case DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE: + d_append_buffer (dpi, dc->u.s_extended_builtin.type->name, + dc->u.s_extended_builtin.type->len); + d_append_num (dpi, dc->u.s_extended_builtin.arg); + if (dc->u.s_extended_builtin.suffix) + d_append_buffer (dpi, &dc->u.s_extended_builtin.suffix, 1); + return; + case DEMANGLE_COMPONENT_VENDOR_TYPE: d_print_comp (dpi, options, d_left (dc)); return; @@ -5525,22 +5716,6 @@ d_print_comp_inner (struct d_print_info *dpi, int options, return; } - case DEMANGLE_COMPONENT_FIXED_TYPE: - if (dc->u.s_fixed.sat) - d_append_string (dpi, "_Sat "); - /* Don't print "int _Accum". */ - if (dc->u.s_fixed.length->u.s_builtin.type - != &cplus_demangle_builtin_types['i'-'a']) - { - d_print_comp (dpi, options, dc->u.s_fixed.length); - d_append_char (dpi, ' '); - } - if (dc->u.s_fixed.accum) - d_append_string (dpi, "_Accum"); - else - d_append_string (dpi, "_Fract"); - return; - case DEMANGLE_COMPONENT_ARGLIST: case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: if (d_left (dc) != NULL) @@ -5908,9 +6083,10 @@ d_print_comp_inner (struct d_print_info *dpi, int options, case DEMANGLE_COMPONENT_PACK_EXPANSION: { - int len; - int i; - struct demangle_component *a = d_find_pack (dpi, d_left (dc)); + struct demangle_component *a = NULL; + + if (!dpi->lambda_tpl_parms) + a = d_find_pack (dpi, d_left (dc)); if (a == NULL) { /* d_find_pack won't find anything if the only packs involved @@ -5918,17 +6094,20 @@ d_print_comp_inner (struct d_print_info *dpi, int options, case, just print the pattern and "...". */ d_print_subexpr (dpi, options, d_left (dc)); d_append_string (dpi, "..."); - return; } - - len = d_pack_length (a); - dc = d_left (dc); - for (i = 0; i < len; ++i) + else { - dpi->pack_index = i; - d_print_comp (dpi, options, dc); - if (i < len-1) - d_append_string (dpi, ", "); + int len = d_pack_length (a); + int i; + + dc = d_left (dc); + for (i = 0; i < len; ++i) + { + if (i) + d_append_string (dpi, ", "); + dpi->pack_index = i; + d_print_comp (dpi, options, dc); + } } } return; @@ -5958,15 +6137,50 @@ d_print_comp_inner (struct d_print_info *dpi, int options, return; case DEMANGLE_COMPONENT_LAMBDA: - d_append_string (dpi, "{lambda("); - /* Generic lambda auto parms are mangled as the template type - parm they are. */ - dpi->is_lambda_arg++; - d_print_comp (dpi, options, dc->u.s_unary_num.sub); - dpi->is_lambda_arg--; - d_append_string (dpi, ")#"); - d_append_num (dpi, dc->u.s_unary_num.num + 1); - d_append_char (dpi, '}'); + { + d_append_string (dpi, "{lambda"); + struct demangle_component *parms = dc->u.s_unary_num.sub; + struct d_print_template dpt; + /* Generic lambda auto parms are mangled as the (synthedic) template + type parm they are. We need to tell the printer that (a) we're in + a lambda, and (b) the number of synthetic parms. */ + int saved_tpl_parms = dpi->lambda_tpl_parms; + dpi->lambda_tpl_parms = 0; + /* Hang any lambda head as-if template args. */ + dpt.template_decl = NULL; + dpt.next = dpi->templates; + dpi->templates = &dpt; + if (parms && parms->type == DEMANGLE_COMPONENT_TEMPLATE_HEAD) + { + dpt.template_decl = parms; + + d_append_char (dpi, '<'); + struct demangle_component *parm; + for (parm = d_left (parms); parm; parm = d_right (parm)) + { + if (dpi->lambda_tpl_parms++) + d_append_string (dpi, ", "); + d_print_comp (dpi, options, parm); + d_append_char (dpi, ' '); + if (parm->type == DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM) + parm = d_left (parm); + d_print_lambda_parm_name (dpi, parm->type, + dpi->lambda_tpl_parms - 1); + } + d_append_char (dpi, '>'); + + parms = d_right (parms); + } + dpi->lambda_tpl_parms++; + + d_append_char (dpi, '('); + d_print_comp (dpi, options, parms); + dpi->lambda_tpl_parms = saved_tpl_parms; + dpi->templates = dpt.next; + d_append_string (dpi, ")#"); + d_append_num (dpi, dc->u.s_unary_num.num + 1); + d_append_char (dpi, '}'); + } return; case DEMANGLE_COMPONENT_UNNAMED_TYPE: @@ -5982,6 +6196,40 @@ d_print_comp_inner (struct d_print_info *dpi, int options, d_append_char (dpi, ']'); return; + case DEMANGLE_COMPONENT_TEMPLATE_HEAD: + { + d_append_char (dpi, '<'); + int count = 0; + struct demangle_component *parm; + for (parm = d_left (dc); parm; parm = d_right (parm)) + { + if (count++) + d_append_string (dpi, ", "); + d_print_comp (dpi, options, parm); + } + d_append_char (dpi, '>'); + } + return; + + case DEMANGLE_COMPONENT_TEMPLATE_TYPE_PARM: + d_append_string (dpi, "typename"); + return; + + case DEMANGLE_COMPONENT_TEMPLATE_NON_TYPE_PARM: + d_print_comp (dpi, options, d_left (dc)); + return; + + case DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM: + d_append_string (dpi, "template"); + d_print_comp (dpi, options, d_left (dc)); + d_append_string (dpi, " class"); + return; + + case DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM: + d_print_comp (dpi, options, d_left (dc)); + d_append_string (dpi, "..."); + return; + default: d_print_error (dpi); return; diff --git a/libiberty/cp-demangle.h b/libiberty/cp-demangle.h index c6445036d67..7f710be4a01 100644 --- a/libiberty/cp-demangle.h +++ b/libiberty/cp-demangle.h @@ -180,7 +180,7 @@ d_advance (struct d_info *di, int i) extern const struct demangle_operator_info cplus_demangle_operators[]; #endif -#define D_BUILTIN_TYPE_COUNT (34) +#define D_BUILTIN_TYPE_COUNT (36) CP_STATIC_IF_GLIBCPP_V3 const struct demangle_builtin_type_info diff --git a/libiberty/functions.texi b/libiberty/functions.texi index e4d74b58220..b56b02e0686 100644 --- a/libiberty/functions.texi +++ b/libiberty/functions.texi @@ -1747,7 +1747,7 @@ that the converted value is unsigned. @c strtoll.c:33 @deftypefn Supplemental {long long int} strtoll (const char *@var{string}, @ char **@var{endptr}, int @var{base}) -@deftypefnx Supplemental {unsigned long long int} strtoul (@ +@deftypefnx Supplemental {unsigned long long int} strtoull (@ const char *@var{string}, char **@var{endptr}, int @var{base}) The @code{strtoll} function converts the string in @var{string} to a diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index 351af349219..d9bc7ed4b1f 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -1242,8 +1242,16 @@ _ZNSt9_Any_data9_M_accessIPZ4postISt8functionIFvvEEEvOT_EUlvE_EERS5_v post >(std::function&&)::{lambda()#1}*& std::_Any_data::_M_access >(post >(std::function&&)::{lambda()#1}*&&)::{lambda()#1}*>() # --format=auto --no-params -_Z3xxxDFyuVb -xxx(unsigned long long _Fract, bool volatile) +_Z3xxxDF16_DF32_DF64_DF128_CDF16_Vb +xxx(_Float16, _Float32, _Float64, _Float128, _Float16 _Complex, bool volatile) +xxx +--format=auto --no-params +_Z3xxxDF32xDF64xDF128xCDF32xVb +xxx(_Float32x, _Float64x, _Float128x, _Float32x _Complex, bool volatile) +xxx +--format=auto --no-params +_Z3xxxDF16b +xxx(std::bfloat16_t) xxx # https://sourceware.org/bugzilla/show_bug.cgi?id=16817 --format=auto --no-params @@ -1570,3 +1578,84 @@ initializer for module Foo.Bar _ZGIW3FooWP3BarW3Baz initializer for module Foo:Bar.Baz + +_ZZ2L1vENKUlDpT_E_clIJiPiEEEvS0_ +void L1()::{lambda((auto:1)...)#1}::operator()(int, int*) const + +_ZZ2L1vENKUlDpT_E_clIJiPiEEEDaS0_ +auto L1()::{lambda((auto:1)...)#1}::operator()(int, int*) const + +_Z7captureIN4gvarMUlvE_EE7WrapperIT_EOS3_ +Wrapper capture(gvar::{lambda()#1}&&) + +_ZNK2L2MUlT_T0_E_clIifEEvS_S0_ +void L2::{lambda(auto:1, auto:2)#1}::operator()(L2, int) const + +_ZNK1C1fMUlT_E_clIMS_iEEDaS1_ +auto C::f::{lambda(auto:1)#1}::operator()(int C::*) const + +_ZNK2L2MUlT_T0_E_clIifEEvS0_S1_ +void L2::{lambda(auto:1, auto:2)#1}::operator()(int, float) const + +_ZNK1B2L3MUlT_T0_E_clIjdEEvS1_S2_ +void B::L3::{lambda(auto:1, auto:2)#1}::operator()(unsigned int, double) const + +_Z3fooIN1qMUlvE_ENS0_UlvE0_EEiOT_OT0_ +int foo(q::{lambda()#1}&&, q::{lambda()#2}&&) + +_ZNK2L1MUlDpT_E_clIJiPiEEEvS1_ +void L1::{lambda((auto:1)...)#1}::operator()(int, int*) const + +_ZZN1XIfLj0EE2FnEvENKUlTyfT_E_clIiEEDafS1_ +auto X::Fn()::{lambda(float, $T0)#1}::operator()(float, int) const + +_ZZN1XIfLj0EE2FnEvENKUlTyT_E_clIiEEDaS1_ +auto X::Fn()::{lambda($T0)#1}::operator()(int) const + +_ZZN1XIfLj1EE2FnEvENKUlTyfT_E_clIiEEDafS1_ +auto X::Fn()::{lambda(float, $T0)#1}::operator()(float, int) const + +_ZZN1XIfLj1EE2FnEvENKUlTyT_E_clIiEEDaS1_ +auto X::Fn()::{lambda($T0)#1}::operator()(int) const + +_ZZN1XIiLj0EE2FnEvENKUlTyiT_E_clIiEEDaiS1_ +auto X::Fn()::{lambda(int, $T0)#1}::operator()(int, int) const + +_ZZN1XIiLj0EE2FnEvENKUlTyT_E_clIiEEDaS1_ +auto X::Fn()::{lambda($T0)#1}::operator()(int) const + +_ZNK10l_tpl_autoMUlTyT_T0_E_clIiiEEDaS0_S1_ +auto l_tpl_auto::{lambda($T0, auto:2)#1}::operator()(int, int) const + +_ZNK12l_tpl_nt_aryMUlTniRAT__iE_clILi2EEEDaS1_ +auto l_tpl_nt_ary::{lambda(int (&) [$N0])#1}::operator()<2>(int (&) [2]) const + +_ZNK13l_tpl_nt_autoMUlTnDavE_clILi0EEEDav +auto l_tpl_nt_auto::{lambda()#1}::operator()<0>() const + +_ZNK9l_tpl_tplMUlTtTyTnjER3TPLIT_EE_clI1UEEDaS3_ +auto l_tpl_tpl::{lambda class $TT0>(TPL<$TT0>&)#1}::operator()(TPL&) const + +_ZNK13l_tpl_tpl_tplMUlTtTtTyTnjEER6TPLTPLIT_EE_clI3TPLEEDaS3_ +auto l_tpl_tpl_tpl::{lambda class> class $TT0>(TPLTPL<$TT0>&)#1}::operator()(TPLTPL&) const + +_ZNK5l_varMUlTpTyDpT_E_clIJiiiEEEDaS1_ +auto l_var::{lambda(($T0)...)#1}::operator()(int, int, int) const + +_ZNK6l_var2MUlTpTniDpRAT__iE_clIJLi2ELi2EEEEDaS2_ +auto l_var2::{lambda((int (&) [$N0])...)#1}::operator()<2, 2>(int (&) [2], int (&) [2]) const + +_ZNK6l_var3MUlTtTpTniETpTniRT_IJXspT0_EEEE_clI1XJLi1ELi2ELi3EEEEDaS2_ +auto l_var3::{lambda class $TT0, int... $N1>($TT0<($N1)...>&)#1}::operator()(X<1, 2, 3>&) const + +_ZNK6l_var4MUlTpTtTyTnjER1YIJDpT_EEE_clIJ1US7_EEEDaS4_ +auto l_var4::{lambda class... $TT0>(Y<($TT0)...>&)#1}::operator()(Y&) const + +_ZZ2FnILi1EEvvENKUlTyT_E_clIiEEDaS0_ +auto Fn<1>()::{lambda($T0)#1}::operator()(int) const + +_ZZ1fvENKUlTyP1XIT_EPS_IiEE_clIcEEDaS2_S4_ +auto f()::{lambda(X<$T0>*, X*)#1}::operator()(X*, X*) const + +_ZZN1XIiE1FEvENKUliE_clEi +X::F()::{lambda(int)#1}::operator()(int) const -- cgit v1.2.1