Skip to content

Commit e2a2633

Browse files
committed
Synchronize sourceware version of the libiberty sources with the master gcc versions.
This brings in the following commits: commit c73cc6fe6207b2863afa31a3be8ad87b70d3df0a Author: Jakub Jelinek <[email protected]> Date: Tue Dec 5 23:32:19 2023 +0100 libiberty: Fix build with GCC < 7 Tobias reported on IRC that the linker fails to build with GCC 4.8.5. In configure I've tried to use everything actually used in the sha1.c x86 hw implementation, but unfortunately I forgot about implicit function declarations. GCC before 7 did have <cpuid.h> header and bit_SHA define and __get_cpuid function defined inline, but it didn't define __get_cpuid_count, which compiled fine (and the configure test is intentionally compile time only) due to implicit function declaration, but then failed to link when linking the linker, because __get_cpuid_count wasn't defined anywhere. The following patch fixes that by using what autoconf uses in AC_CHECK_DECL to make sure the functions are declared. commit 691858d279335eeeeed3afafdf872b1c5f8f4201 Author: Rainer Orth <[email protected]> Date: Tue Dec 5 11:04:06 2023 +0100 libiberty: Fix pex_unix_wait return type The recent warning patches broke Solaris bootstrap: /vol/gcc/src/hg/master/local/libiberty/pex-unix.c:326:3: error: initialization of 'pid_t (*)(struct pex_obj *, pid_t, int *, struct pex_time *, int, const char **, int *)' {aka 'long int (*)(struct pex_obj *, long int, int *, struct pex_time *, int, const char **, int *)'} from incompatible pointer type 'int (*)(struct pex_obj *, pid_t, int *, struct pex_time *, int, const char **, int *)' {aka 'int (*)(struct pex_obj *, long int, int *, struct pex_time *, int, const char **, int *)'} [-Wincompatible-pointer-types] 326 | pex_unix_wait, | ^~~~~~~~~~~~~ /vol/gcc/src/hg/master/local/libiberty/pex-unix.c:326:3: note: (near initialization for 'funcs.wait') While pex_funcs.wait expects a function returning pid_t, pex_unix_wait currently returns int. However, on Solaris pid_t is long for 32-bit, but int for 64-bit. This patches fixes this by having pex_unix_wait return pid_t as expected, and like every other variant already does. Bootstrapped without regressions on i386-pc-solaris2.11, sparc-sun-solaris2.11, x86_64-pc-linux-gnu, and x86_64-apple-darwin23.1.0. commit c3f281a0c1ca50e4df5049923aa2f5d1c3c39ff6 Author: Jason Merrill <[email protected]> Date: Mon Sep 25 10:15:02 2023 +0100 c++: mangle function template constraints Per itanium-cxx-abi/cxx-abi#24 and itanium-cxx-abi/cxx-abi#166 We need to mangle constraints to be able to distinguish between function templates that only differ in constraints. From the latter link, we want to use the template parameter mangling previously specified for lambdas to also make explicit the form of a template parameter where the argument is not a "natural" fit for it, such as when the parameter is constrained or deduced. I'm concerned about how the latter link changes the mangling for some C++98 and C++11 patterns, so I've limited template_parm_natural_p to avoid two cases found by running the testsuite with -Wabi forced on: template <class T, T V> T f() { return V; } int main() { return f<int,42>(); } template <int i> int max() { return i; } template <int i, int j, int... rest> int max() { int sub = max<j, rest...>(); return i > sub ? i : sub; } int main() { return max<1,2,3>(); } A third C++11 pattern is changed by this patch: template <template <typename...> class TT, typename... Ts> TT<Ts...> f(); template <typename> struct A { }; int main() { f<A,int>(); } I aim to resolve these with the ABI committee before GCC 14.1. We also need to resolve itanium-cxx-abi/cxx-abi#38 (mangling references to dependent template-ids where the name is fully resolved) as references to concepts in std:: will consistently run into this area. This is why mangle-concepts1.C only refers to concepts in the global namespace so far. The library changes are to avoid trying to mangle builtins, which fails. Demangler support and test coverage is not complete yet. commit f2c52c0dfde581461959b0e2b423ad106aadf179 Author: Rainer Orth <[email protected]> Date: Thu Nov 30 10:06:23 2023 +0100 libiberty: Disable hwcaps for sha1.o This patch commit bf4f40cc3195eb7b900bf5535cdba1ee51fdbb8e Author: Jakub Jelinek <[email protected]> Date: Tue Nov 28 13:14:05 2023 +0100 libiberty: Use x86 HW optimized sha1 broke Solaris/x86 bootstrap with the native as: libtool: compile: /var/gcc/regression/master/11.4-gcc/build/./gcc/gccgo -B/var/gcc/regression/master/11.4-gcc/build/./gcc/ -B/vol/gcc/i386-pc-solaris2.11/bin/ -B/vol/gcc/i386-pc-solaris2.11/lib/ -isystem /vol/gcc/i386-pc-solaris2.11/include -isystem /vol/gcc/i386-pc-solaris2.11/sys-include -fchecking=1 -minline-all-stringops -O2 -g -I . -c -fgo-pkgpath=internal/goarch /vol/gcc/src/hg/master/local/libgo/go/internal/goarch/goarch.go zgoarch.go ld.so.1: go1: fatal: /var/gcc/regression/master/11.4-gcc/build/gcc/go1: hardware capability (CA_SUNW_HW_2) unsupported: 0x4000000 [ SHA1 ] gccgo: fatal error: Killed signal terminated program go1 As is already done in a couple of other similar cases, this patches disables hwcaps support for libiberty. Initially, this didn't work because config/hwcaps.m4 uses target_os, but didn't ensure it is defined. Tested on i386-pc-solaris2.11 with as and gas. commit bf4f40cc3195eb7b900bf5535cdba1ee51fdbb8e Author: Jakub Jelinek <[email protected]> Date: Tue Nov 28 13:14:05 2023 +0100 libiberty: Use x86 HW optimized sha1 Nick has approved this patch (+ small ld change to use it for --build-id=), so I'm commiting it to GCC as master as well. If anyone from ARM would be willing to implement it similarly with vsha1{cq,mq,pq,h,su0q,su1q}_u32 intrinsics, it could be a useful linker speedup on those hosts as well, the intent in sha1.c was that sha1_hw_process_bytes, sha1_hw_process_block functions would be defined whenever defined (HAVE_X86_SHA1_HW_SUPPORT) || defined (HAVE_WHATEVERELSE_SHA1_HW_SUPPORT) but the body of sha1_hw_process_block and sha1_choose_process_bytes would then have #elif defined (HAVE_WHATEVERELSE_SHA1_HW_SUPPORT) for the other arch support, similarly for any target attributes on sha1_hw_process_block if needed. commit 01bc30b222a9d2ff0269325d9e367f8f1fcef942 Author: Mark Wielaard <[email protected]> Date: Wed Nov 15 20:27:08 2023 +0100 Regenerate libiberty/aclocal.m4 with aclocal 1.15.1 There is a new buildbot check that all autotool files are generated with the correct versions (automake 1.15.1 and autoconf 2.69). https://builder.sourceware.org/buildbot/#/builders/gcc-autoregen Correct one file that was generated with the wrong version. commit 879cf9ff45d94065d89e24b71c6b27c7076ac518 Author: Brendan Shanks <[email protected]> Date: Thu Nov 9 21:01:07 2023 -0700 [PATCH v3] libiberty: Use posix_spawn in pex-unix when available. Hi, This patch implements pex_unix_exec_child using posix_spawn when available. This should especially benefit recent macOS (where vfork just calls fork), but should have equivalent or faster performance on all platforms. In addition, the implementation is substantially simpler than the vfork+exec code path. Tested on x86_64-linux. v2: Fix error handling (previously the function would be run twice in case of error), and don't use a macro that changes control flow. v3: Match file style for error-handling blocks, don't close in/out/errdes on error, and check close() for errors. commit 810bcc00156cefce7ad40fc9d8de6e43c3a04450 Author: Jason Merrill <[email protected]> Date: Thu Aug 17 11:36:23 2023 -0400 c++: constrained hidden friends [PR109751] r13-4035 avoided a problem with overloading of constrained hidden friends by checking satisfaction, but checking satisfaction early is inconsistent with the usual late checking and can lead to hard errors, so let's not do that after all. We were wrongly treating the different instantiations of the same friend template as the same function because maybe_substitute_reqs_for was failing to actually substitute in the case of a non-template friend. But we don't actually need to do the substitution anyway, because [temp.friend] says that such a friend can't be the same as any other declaration. After fixing that, instead of a redefinition error we got an ambiguous overload error, fixed by allowing constrained hidden friends to coexist until overload resolution, at which point they probably won't be in the same ADL overload set anyway. And we avoid mangling collisions by following the proposed mangling for these friends as a member function with an extra 'F' before the name. I demangle this by just adding [friend] to the name of the function because it's not feasible to reconstruct the actual scope of the function since the mangling ABI doesn't distinguish between class and namespace scopes. PR c++/109751
1 parent e318eb0 commit e2a2633

File tree

8 files changed

+342
-31
lines changed

8 files changed

+342
-31
lines changed

include/demangle.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ enum demangle_component_type
448448
DEMANGLE_COMPONENT_TRANSACTION_SAFE,
449449
/* A cloned function. */
450450
DEMANGLE_COMPONENT_CLONE,
451+
/* A member-like friend function. */
452+
DEMANGLE_COMPONENT_FRIEND,
451453
DEMANGLE_COMPONENT_NOEXCEPT,
452454
DEMANGLE_COMPONENT_THROW_SPEC,
453455

@@ -464,6 +466,8 @@ enum demangle_component_type
464466
DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM,
465467
DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM,
466468

469+
DEMANGLE_COMPONENT_CONSTRAINTS,
470+
467471
/* A builtin type with argument. This holds the builtin type
468472
information. */
469473
DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE

libiberty/ChangeLog

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
__get_cpuid_count are not implicitly declared.
55
* configure: Regenerated.
66

7+
2023-12-05 Rainer Orth <[email protected]>
8+
9+
* pex-unix.c (pex_unix_wait): Change return type to pid_t.
10+
11+
2023-12-01 Jason Merrill <[email protected]>
12+
13+
* cp-demangle.c (d_make_comp): Handle
14+
DEMANGLE_COMPONENT_CONSTRAINTS.
15+
(d_count_templates_scopes): Likewise.
16+
(d_print_comp_inner): Likewise.
17+
(d_maybe_constraints): New.
18+
(d_encoding, d_template_args_1): Call it.
19+
(d_parmlist): Handle 'Q'.
20+
* testsuite/demangle-expected: Add some constraint tests.
21+
722
2023-11-30 Rainer Orth <[email protected]>
823

924
* configure.ac (GCC_CHECK_ASSEMBLER_HWCAP): Invoke.
@@ -20,6 +35,45 @@
2035
* config.in: Regenerated.
2136
* configure: Regenerated.
2237

38+
2023-11-15 Mark Wielaard <[email protected]>
39+
40+
* aclocal.m4: Rebuild.
41+
42+
2023-11-10 Brendan Shanks <[email protected]>
43+
44+
* configure.ac (AC_CHECK_HEADERS): Add spawn.h.
45+
(checkfuncs): Add posix_spawn, posix_spawnp.
46+
(AC_CHECK_FUNCS): Add posix_spawn, posix_spawnp.
47+
* aclocal.m4, configure, config.in: Rebuild.
48+
* pex-unix.c [HAVE_POSIX_SPAWN] (pex_unix_exec_child): New function.
49+
50+
2023-08-22 Jason Merrill <[email protected]>
51+
52+
PR c++/109751
53+
* cp-demangle.c (d_make_comp): Handle DEMANGLE_COMPONENT_FRIEND.
54+
(d_count_templates_scopes): Likewise.
55+
(d_print_comp_inner): Likewise.
56+
(d_unqualified_name): Handle member-like friend mangling.
57+
* testsuite/demangle-expected: Add test.
58+
59+
2023-08-07 John Ericson <[email protected]>
60+
61+
* configure: Regenerate.
62+
63+
2023-08-07 H.J. Lu <[email protected]>
64+
65+
* configure: Regenerate.
66+
67+
2023-08-07 H.J. Lu <[email protected]>
68+
69+
* Makefile.in (AR): Add @AR_PLUGIN_OPTION@
70+
(RANLIB): Add @RANLIB_PLUGIN_OPTION@.
71+
(configure_deps): Depend on ../config/gcc-plugin.m4.
72+
* configure.ac: AC_SUBST AR_PLUGIN_OPTION and
73+
RANLIB_PLUGIN_OPTION.
74+
* aclocal.m4: Regenerated.
75+
* configure: Likewise.
76+
2377
2023-06-15 Marek Polacek <[email protected]>
2478

2579
* configure.ac: Also set shared when enable_host_pie.

libiberty/config.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@
198198
/* Define to 1 if you have the `pipe2' function. */
199199
#undef HAVE_PIPE2
200200

201+
/* Define to 1 if you have the `posix_spawn' function. */
202+
#undef HAVE_POSIX_SPAWN
203+
204+
/* Define to 1 if you have the `posix_spawnp' function. */
205+
#undef HAVE_POSIX_SPAWNP
206+
201207
/* Define to 1 if you have the <process.h> header file. */
202208
#undef HAVE_PROCESS_H
203209

@@ -249,6 +255,9 @@
249255
/* Define to 1 if you have the `spawnvpe' function. */
250256
#undef HAVE_SPAWNVPE
251257

258+
/* Define to 1 if you have the <spawn.h> header file. */
259+
#undef HAVE_SPAWN_H
260+
252261
/* Define to 1 if you have the <stdint.h> header file. */
253262
#undef HAVE_STDINT_H
254263

libiberty/configure

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5746,7 +5746,7 @@ host_makefile_frag=${frag}
57465746
# It's OK to check for header files. Although the compiler may not be
57475747
# able to link anything, it had better be able to at least compile
57485748
# something.
5749-
for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h
5749+
for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h
57505750
do :
57515751
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
57525752
ac_fn_c_check_header_preproc "$LINENO" "$ac_header" "$as_ac_Header"
@@ -6255,7 +6255,8 @@ funcs="$funcs setproctitle"
62556255
vars="sys_errlist sys_nerr sys_siglist"
62566256
62576257
checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \
6258-
getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \
6258+
getsysinfo gettimeofday on_exit pipe2 posix_spawn posix_spawnp psignal \
6259+
pstat_getdynamic pstat_getstatic \
62596260
realpath setrlimit spawnve spawnvpe strerror strsignal sysconf sysctl \
62606261
sysmp table times wait3 wait4"
62616262
@@ -6278,7 +6279,8 @@ if test "x" = "y"; then
62786279
index insque \
62796280
memchr memcmp memcpy memmem memmove memset mkstemps \
62806281
on_exit \
6281-
pipe2 psignal pstat_getdynamic pstat_getstatic putenv \
6282+
pipe2 posix_spawn posix_spawnp psignal \
6283+
pstat_getdynamic pstat_getstatic putenv \
62826284
random realpath rename rindex \
62836285
sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \
62846286
stpcpy stpncpy strcasecmp strchr strdup \

libiberty/configure.ac

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ AC_SUBST_FILE(host_makefile_frag)
291291
# It's OK to check for header files. Although the compiler may not be
292292
# able to link anything, it had better be able to at least compile
293293
# something.
294-
AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h)
294+
AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h)
295295
AC_HEADER_SYS_WAIT
296296
AC_HEADER_TIME
297297

@@ -414,7 +414,8 @@ funcs="$funcs setproctitle"
414414
vars="sys_errlist sys_nerr sys_siglist"
415415

416416
checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \
417-
getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \
417+
getsysinfo gettimeofday on_exit pipe2 posix_spawn posix_spawnp psignal \
418+
pstat_getdynamic pstat_getstatic \
418419
realpath setrlimit spawnve spawnvpe strerror strsignal sysconf sysctl \
419420
sysmp table times wait3 wait4"
420421

@@ -437,7 +438,8 @@ if test "x" = "y"; then
437438
index insque \
438439
memchr memcmp memcpy memmem memmove memset mkstemps \
439440
on_exit \
440-
pipe2 psignal pstat_getdynamic pstat_getstatic putenv \
441+
pipe2 posix_spawn posix_spawnp psignal \
442+
pstat_getdynamic pstat_getstatic putenv \
441443
random realpath rename rindex \
442444
sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \
443445
stpcpy stpncpy strcasecmp strchr strdup \

libiberty/cp-demangle.c

Lines changed: 83 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type,
993993
case DEMANGLE_COMPONENT_VECTOR_TYPE:
994994
case DEMANGLE_COMPONENT_CLONE:
995995
case DEMANGLE_COMPONENT_MODULE_ENTITY:
996+
case DEMANGLE_COMPONENT_CONSTRAINTS:
996997
if (left == NULL || right == NULL)
997998
return NULL;
998999
break;
@@ -1036,6 +1037,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type,
10361037
case DEMANGLE_COMPONENT_TEMPLATE_NON_TYPE_PARM:
10371038
case DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM:
10381039
case DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM:
1040+
case DEMANGLE_COMPONENT_FRIEND:
10391041
if (left == NULL)
10401042
return NULL;
10411043
break;
@@ -1344,6 +1346,22 @@ is_ctor_dtor_or_conversion (struct demangle_component *dc)
13441346
}
13451347
}
13461348

1349+
/* [ Q <constraint-expression> ] */
1350+
1351+
static struct demangle_component *
1352+
d_maybe_constraints (struct d_info *di, struct demangle_component *dc)
1353+
{
1354+
if (d_peek_char (di) == 'Q')
1355+
{
1356+
d_advance (di, 1);
1357+
struct demangle_component *expr = d_expression (di);
1358+
if (expr == NULL)
1359+
return NULL;
1360+
dc = d_make_comp (di, DEMANGLE_COMPONENT_CONSTRAINTS, dc, expr);
1361+
}
1362+
return dc;
1363+
}
1364+
13471365
/* <encoding> ::= <(function) name> <bare-function-type>
13481366
::= <(data) name>
13491367
::= <special-name>
@@ -1397,21 +1415,21 @@ d_encoding (struct d_info *di, int top_level)
13971415
struct demangle_component *ftype;
13981416

13991417
ftype = d_bare_function_type (di, has_return_type (dc));
1400-
if (ftype)
1401-
{
1402-
/* If this is a non-top-level local-name, clear the
1403-
return type, so it doesn't confuse the user by
1404-
being confused with the return type of whaever
1405-
this is nested within. */
1406-
if (!top_level && dc->type == DEMANGLE_COMPONENT_LOCAL_NAME
1407-
&& ftype->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
1408-
d_left (ftype) = NULL;
1409-
1410-
dc = d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME,
1411-
dc, ftype);
1412-
}
1413-
else
1414-
dc = NULL;
1418+
if (!ftype)
1419+
return NULL;
1420+
1421+
/* If this is a non-top-level local-name, clear the
1422+
return type, so it doesn't confuse the user by
1423+
being confused with the return type of whaever
1424+
this is nested within. */
1425+
if (!top_level && dc->type == DEMANGLE_COMPONENT_LOCAL_NAME
1426+
&& ftype->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
1427+
d_left (ftype) = NULL;
1428+
1429+
ftype = d_maybe_constraints (di, ftype);
1430+
1431+
dc = d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME,
1432+
dc, ftype);
14151433
}
14161434
}
14171435
}
@@ -1681,6 +1699,7 @@ d_maybe_module_name (struct d_info *di, struct demangle_component **name)
16811699
/* <unqualified-name> ::= [<module-name>] <operator-name> [<abi-tags>]
16821700
::= [<module-name>] <ctor-dtor-name> [<abi-tags>]
16831701
::= [<module-name>] <source-name> [<abi-tags>]
1702+
::= [<module-name>] F <source-name> [<abi-tags>]
16841703
::= [<module-name>] <local-source-name> [<abi-tags>]
16851704
::= [<module-name>] DC <source-name>+ E [<abi-tags>]
16861705
<local-source-name> ::= L <source-name> <discriminator> [<abi-tags>]
@@ -1692,11 +1711,18 @@ d_unqualified_name (struct d_info *di, struct demangle_component *scope,
16921711
{
16931712
struct demangle_component *ret;
16941713
char peek;
1714+
int member_like_friend = 0;
16951715

16961716
if (!d_maybe_module_name (di, &module))
16971717
return NULL;
16981718

16991719
peek = d_peek_char (di);
1720+
if (peek == 'F')
1721+
{
1722+
member_like_friend = 1;
1723+
d_advance (di, 1);
1724+
peek = d_peek_char (di);
1725+
}
17001726
if (IS_DIGIT (peek))
17011727
ret = d_source_name (di);
17021728
else if (IS_LOWER (peek))
@@ -1773,6 +1799,8 @@ d_unqualified_name (struct d_info *di, struct demangle_component *scope,
17731799
ret = d_make_comp (di, DEMANGLE_COMPONENT_MODULE_ENTITY, ret, module);
17741800
if (d_peek_char (di) == 'B')
17751801
ret = d_abi_tags (di, ret);
1802+
if (member_like_friend)
1803+
ret = d_make_comp (di, DEMANGLE_COMPONENT_FRIEND, ret, NULL);
17761804
if (scope)
17771805
ret = d_make_comp (di, DEMANGLE_COMPONENT_QUAL_NAME, scope, ret);
17781806

@@ -3012,7 +3040,7 @@ d_parmlist (struct d_info *di)
30123040
struct demangle_component *type;
30133041

30143042
char peek = d_peek_char (di);
3015-
if (peek == '\0' || peek == 'E' || peek == '.')
3043+
if (peek == '\0' || peek == 'E' || peek == '.' || peek == 'Q')
30163044
break;
30173045
if ((peek == 'R' || peek == 'O')
30183046
&& d_peek_next_char (di) == 'E')
@@ -3248,7 +3276,7 @@ d_template_args (struct d_info *di)
32483276
return d_template_args_1 (di);
32493277
}
32503278

3251-
/* <template-arg>* E */
3279+
/* <template-arg>* [Q <constraint-expression>] E */
32523280

32533281
static struct demangle_component *
32543282
d_template_args_1 (struct d_info *di)
@@ -3284,13 +3312,17 @@ d_template_args_1 (struct d_info *di)
32843312
return NULL;
32853313
pal = &d_right (*pal);
32863314

3287-
if (d_peek_char (di) == 'E')
3288-
{
3289-
d_advance (di, 1);
3290-
break;
3291-
}
3315+
char peek = d_peek_char (di);
3316+
if (peek == 'E' || peek == 'Q')
3317+
break;
32923318
}
32933319

3320+
al = d_maybe_constraints (di, al);
3321+
3322+
if (d_peek_char (di) != 'E')
3323+
return NULL;
3324+
d_advance (di, 1);
3325+
32943326
di->last_name = hold_last_name;
32953327

32963328
return al;
@@ -4431,6 +4463,7 @@ d_count_templates_scopes (struct d_print_info *dpi,
44314463
case DEMANGLE_COMPONENT_PACK_EXPANSION:
44324464
case DEMANGLE_COMPONENT_TAGGED_NAME:
44334465
case DEMANGLE_COMPONENT_CLONE:
4466+
case DEMANGLE_COMPONENT_CONSTRAINTS:
44344467
recurse_left_right:
44354468
/* PR 89394 - Check for too much recursion. */
44364469
if (dpi->recursion > DEMANGLE_RECURSION_LIMIT)
@@ -4459,6 +4492,7 @@ d_count_templates_scopes (struct d_print_info *dpi,
44594492
case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS:
44604493
case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS:
44614494
case DEMANGLE_COMPONENT_MODULE_ENTITY:
4495+
case DEMANGLE_COMPONENT_FRIEND:
44624496
d_count_templates_scopes (dpi, d_left (dc));
44634497
break;
44644498

@@ -5189,6 +5223,22 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
51895223
dpt.next = dpi->templates;
51905224
dpi->templates = &dpt;
51915225
dpt.template_decl = typed_name;
5226+
5227+
/* Constraints are mangled as part of the template argument list,
5228+
so they wrap the _TEMPLATE_ARGLIST. But
5229+
d_lookup_template_argument expects the RHS of _TEMPLATE to be
5230+
the _ARGLIST, and constraints need to refer to these args. So
5231+
move the _CONSTRAINTS out of the _TEMPLATE and onto the type.
5232+
This will result in them being printed after the () like a
5233+
trailing requires-clause, but that seems like our best option
5234+
given that we aren't printing a template-head. */
5235+
struct demangle_component *tnr = d_right (typed_name);
5236+
if (tnr->type == DEMANGLE_COMPONENT_CONSTRAINTS)
5237+
{
5238+
d_right (typed_name) = d_left (tnr);
5239+
d_left (tnr) = d_right (dc);
5240+
d_right (dc) = tnr;
5241+
}
51925242
}
51935243

51945244
d_print_comp (dpi, options, d_right (dc));
@@ -6197,6 +6247,11 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
61976247
d_append_char (dpi, ']');
61986248
return;
61996249

6250+
case DEMANGLE_COMPONENT_FRIEND:
6251+
d_print_comp (dpi, options, d_left (dc));
6252+
d_append_string (dpi, "[friend]");
6253+
return;
6254+
62006255
case DEMANGLE_COMPONENT_TEMPLATE_HEAD:
62016256
{
62026257
d_append_char (dpi, '<');
@@ -6231,6 +6286,12 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
62316286
d_append_string (dpi, "...");
62326287
return;
62336288

6289+
case DEMANGLE_COMPONENT_CONSTRAINTS:
6290+
d_print_comp (dpi, options, d_left (dc));
6291+
d_append_string (dpi, " requires ");
6292+
d_print_comp (dpi, options, d_right (dc));
6293+
return;
6294+
62346295
default:
62356296
d_print_error (dpi);
62366297
return;

0 commit comments

Comments
 (0)