diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-11-11 15:11:23 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2020-11-11 15:11:23 -0500 |
commit | b1c9b3c3408c1ec8043f9b9e1a148f84bb7f3b25 (patch) | |
tree | 005cdc1c5d50f3abaf02bd6680a57bf9c489de81 /libiberty | |
parent | 61827d5d9a5a09a8c05d5e41f95b03ebc6c43f61 (diff) | |
download | gcc-b1c9b3c3408c1ec8043f9b9e1a148f84bb7f3b25.zip gcc-b1c9b3c3408c1ec8043f9b9e1a148f84bb7f3b25.tar.gz gcc-b1c9b3c3408c1ec8043f9b9e1a148f84bb7f3b25.tar.bz2 |
c++: Change the mangling of __alignof__ [PR88115]
This patch changes the mangling of __alignof__ to v111__alignof__,
making its mangling distinct from that of alignof(type) and
alignof(expr).
How we mangle ALIGNOF_EXPR now depends on its ALIGNOF_EXPR_STD_P flag,
which after the previous patch gets consistently set for alignof(type)
as well as alignof(expr).
gcc/c-family/ChangeLog:
PR c++/88115
* c-opts.c (c_common_post_options): Update latest_abi_version.
gcc/ChangeLog:
PR c++/88115
* common.opt (-fabi-version): Document =15.
* doc/invoke.texi (C++ Dialect Options): Likewise.
gcc/cp/ChangeLog:
PR c++/88115
* mangle.c (write_expression): Mangle __alignof_ differently
from alignof when the ABI version is at least 15.
libiberty/ChangeLog:
PR c++/88115
* cp-demangle.c (d_print_comp_inner)
<case DEMANGLE_COMPONENT_EXTENDED_OPERATOR>: Don't print the
"operator " prefix for __alignof__.
<case DEMANGLE_COMPONENT_UNARY>: Always print parens around the
operand of __alignof__.
* testsuite/demangle-expected: Test demangling for __alignof__.
gcc/testsuite/ChangeLog:
PR c++/88115
* g++.dg/abi/macro0.C: Adjust.
* g++.dg/cpp0x/alignof7.C: New test.
* g++.dg/cpp0x/alignof8.C: New test.
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/cp-demangle.c | 25 | ||||
-rw-r--r-- | libiberty/testsuite/demangle-expected | 7 |
2 files changed, 27 insertions, 5 deletions
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index aede23f..a9f8e75 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -5458,9 +5458,18 @@ d_print_comp_inner (struct d_print_info *dpi, int options, } case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: - d_append_string (dpi, "operator "); - d_print_comp (dpi, options, dc->u.s_extended_operator.name); - return; + { + struct demangle_component *name = dc->u.s_extended_operator.name; + if (name->type == DEMANGLE_COMPONENT_NAME + && !strncmp (name->u.s_name.s, "__alignof__", name->u.s_name.len)) + d_print_comp (dpi, options, dc->u.s_extended_operator.name); + else + { + d_append_string (dpi, "operator "); + d_print_comp (dpi, options, dc->u.s_extended_operator.name); + } + return; + } case DEMANGLE_COMPONENT_CONVERSION: d_append_string (dpi, "operator "); @@ -5525,8 +5534,14 @@ d_print_comp_inner (struct d_print_info *dpi, int options, if (code && !strcmp (code, "gs")) /* Avoid parens after '::'. */ d_print_comp (dpi, options, operand); - else if (code && !strcmp (code, "st")) - /* Always print parens for sizeof (type). */ + else if ((code && !strcmp (code, "st")) + || (op->type == DEMANGLE_COMPONENT_EXTENDED_OPERATOR + && (op->u.s_extended_operator.name->type + == DEMANGLE_COMPONENT_NAME) + && !strncmp (op->u.s_extended_operator.name->u.s_name.s, + "__alignof__", + op->u.s_extended_operator.name->u.s_name.len))) + /* Always print parens for sizeof (type) and __alignof__. */ { d_append_char (dpi, '('); d_print_comp (dpi, options, operand); diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index 0850db3..4ad9da8 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -1469,3 +1469,10 @@ f(A<X{.a.b[3 ... 4]=(1)}>) # PR 96143 _Z2F2IZ1FvEUlvE_EN1AIT_E1XES2_ A<F()::{lambda()#1}>::X F2<F()::{lambda()#1}>(F()::{lambda()#1}) + +# PR 88115 +_Z1fIiEvDTv111__alignof__T_E +void f<int>(decltype (__alignof__(int))) + +_Z1fIiEvDTv111__alignof__tlT_EE +void f<int>(decltype (__alignof__(int{}))) |