summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrippels <trippels@138bc75d-0d04-0410-961f-82ee72b054a4>2017-01-18 08:49:11 +0000
committertrippels <trippels@138bc75d-0d04-0410-961f-82ee72b054a4>2017-01-18 08:49:11 +0000
commit322066d8fcd41ad6d9f78baa038841984d79e255 (patch)
treed4fd72c31d0897c52a3930c438870be3b370022a
parenta2929a3a9a9ad7dea28a2c76f0124a9fa5e58238 (diff)
downloadgcc-322066d8fcd41ad6d9f78baa038841984d79e255.tar.gz
Fix PR70182 -- missing "on" in mangling of unresolved operators
The ABI says: <unresolved-name> ::= [gs] <base-unresolved-name> ::= sr <unresolved-type> <base-unresolved-name> ::= srN <unresolved-type> <unresolved-qualifier-level>+ E <base-unresolved-name> ::= [gs] sr <unresolved-qualifier-level>+ E <base-unresolved-name> <base-unresolved-name> ::= <simple-id> ::= on <operator-name> ::= on <operator-name> <template-args> ::= dn <destructor-name libiberty: PR c++/70182 * cp-demangle.c (d_unqualified_name): Handle "on" for operator names. * testsuite/demangle-expected: Add tests. gcc/cp: PR c++/70182 * mangle.c (write_template_args): Add "on" for operator names. gcc: PR c++/70182 * doc/invoke.texi (fabi-version): Mention mangling fix for operator names. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@244567 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/mangle.c6
-rw-r--r--gcc/doc/invoke.texi8
-rw-r--r--gcc/testsuite/g++.dg/abi/mangle13.C2
-rw-r--r--gcc/testsuite/g++.dg/abi/mangle37.C1
-rw-r--r--gcc/testsuite/g++.dg/abi/pr70182.C28
-rw-r--r--gcc/testsuite/g++.dg/dfp/mangle-1.C1
-rw-r--r--libiberty/ChangeLog7
-rw-r--r--libiberty/cp-demangle.c2
-rw-r--r--libiberty/testsuite/demangle-expected7
11 files changed, 68 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 13a7015ccc2..257a21d30cf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2017-01-18 Markus Trippelsdorf <markus@trippelsdorf.de>
+ PR c++/70182
+ * doc/invoke.texi (fabi-version): Mention mangling fix for
+ operator names.
+
+2017-01-18 Markus Trippelsdorf <markus@trippelsdorf.de>
+
PR c++/77489
* doc/invoke.texi (fabi-version): Document discriminator mangling.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 86669ae1371..a42454a478a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2017-01-18 Markus Trippelsdorf <markus@trippelsdorf.de>
+ PR c++/70182
+ * mangle.c (write_template_args): Add "on" for operator names.
+
+2017-01-18 Markus Trippelsdorf <markus@trippelsdorf.de>
+
PR c++/77489
* mangle.c (write_discriminator): Handle discriminator >= 10.
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 67ec5c31f17..d1b107cbb1d 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -2817,6 +2817,12 @@ write_template_args (tree args)
static void
write_member_name (tree member)
{
+ if (abi_version_at_least (11) && IDENTIFIER_OPNAME_P (member))
+ {
+ write_string ("on");
+ if (abi_warn_or_compat_version_crosses (11))
+ G.need_abi_warning = 1;
+ }
if (identifier_p (member))
write_unqualified_id (member);
else if (DECL_P (member))
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 767c8f42fee..06e3ae86664 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2252,10 +2252,10 @@ attributes that affect type identity, such as ia32 calling convention
attributes (e.g. @samp{stdcall}).
Version 11, which first appeared in G++ 7, corrects the mangling of
-sizeof... expressions. For multiple entities with the same name within
-a function, that are declared in different scopes, the mangling now
-changes starting with the eighth occurence. It also implies
-@option{-fnew-inheriting-ctors}.
+sizeof... expressions and operator names. For multiple entities with
+the same name within a function, that are declared in different scopes,
+the mangling now changes starting with the eighth occurence. It also
+implies @option{-fnew-inheriting-ctors}.
See also @option{-Wabi}.
diff --git a/gcc/testsuite/g++.dg/abi/mangle13.C b/gcc/testsuite/g++.dg/abi/mangle13.C
index 716c4c36f41..c8822a34039 100644
--- a/gcc/testsuite/g++.dg/abi/mangle13.C
+++ b/gcc/testsuite/g++.dg/abi/mangle13.C
@@ -1,4 +1,4 @@
-// { dg-options "-fabi-version=0" }
+// { dg-options "-fabi-version=10" }
struct A {
template <typename T> int f ();
diff --git a/gcc/testsuite/g++.dg/abi/mangle37.C b/gcc/testsuite/g++.dg/abi/mangle37.C
index 691566b384b..4dd87e84c10 100644
--- a/gcc/testsuite/g++.dg/abi/mangle37.C
+++ b/gcc/testsuite/g++.dg/abi/mangle37.C
@@ -1,5 +1,6 @@
// Testcase for mangling of expressions involving operator names.
// { dg-do compile { target c++11 } }
+// { dg-options "-fabi-version=10" }
// { dg-final { scan-assembler "_Z1fI1AEDTclonplfp_fp_EET_" } }
// { dg-final { scan-assembler "_Z1gI1AEDTclonplIT_Efp_fp_EES1_" } }
// { dg-final { scan-assembler "_Z1hI1AEDTcldtfp_miEET_" } }
diff --git a/gcc/testsuite/g++.dg/abi/pr70182.C b/gcc/testsuite/g++.dg/abi/pr70182.C
new file mode 100644
index 00000000000..d299362910c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/pr70182.C
@@ -0,0 +1,28 @@
+// { dg-options "-fabi-version=0" }
+
+struct A {
+ template <typename T> int f ();
+ int operator+();
+ operator int ();
+ template <typename T>
+ int operator-();
+};
+
+typedef int (A::*P)();
+
+template <P> struct S {};
+
+template <typename T> void g (S<&T::template f<int> >) {}
+template <typename T> void g (S<&T::operator+ >) {}
+template <typename T> void g (S<&T::operator int>) {}
+template <typename T> void g (S<&T::template operator- <double> >) {}
+
+template void g<A> (S<&A::f<int> >);
+template void g<A> (S<&A::operator+>);
+template void g<A> (S<&A::operator int>);
+template void g<A> (S<&A::operator-<double> >);
+
+// { dg-final { scan-assembler _Z1gI1AEv1SIXadsrT_1fIiEEE } }
+// { dg-final { scan-assembler _Z1gI1AEv1SIXadsrT_onplEE } }
+// { dg-final { scan-assembler _Z1gI1AEv1SIXadsrT_oncviEE } }
+// { dg-final { scan-assembler _Z1gI1AEv1SIXadsrT_onmiIdEEE } }
diff --git a/gcc/testsuite/g++.dg/dfp/mangle-1.C b/gcc/testsuite/g++.dg/dfp/mangle-1.C
index 455d3e4c0ef..ee9644b27a5 100644
--- a/gcc/testsuite/g++.dg/dfp/mangle-1.C
+++ b/gcc/testsuite/g++.dg/dfp/mangle-1.C
@@ -1,4 +1,5 @@
// { dg-do compile }
+// { dg-options "-fabi-version=10" }
// Mangling of classes from std::decimal are special-cased.
// Derived from g++.dg/abi/mangle13.C.
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 104907c84c8..0c5972a1844 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,5 +1,12 @@
2017-01-18 Markus Trippelsdorf <markus@trippelsdorf.de>
+ PR PR c++/70182
+ * cp-demangle.c (d_unqualified_name): Handle "on" for
+ operator names.
+ * testsuite/demangle-expected: Add tests.
+
+2017-01-18 Markus Trippelsdorf <markus@trippelsdorf.de>
+
PR c++/77489
* cp-demangle.c (d_discriminator): Handle discriminator >= 10.
* testsuite/demangle-expected: Add tests for discriminator.
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index d84929eca20..f0dbf9381c6 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1594,6 +1594,8 @@ d_unqualified_name (struct d_info *di)
ret = d_source_name (di);
else if (IS_LOWER (peek))
{
+ if (peek == 'o' && d_peek_next_char (di) == 'n')
+ d_advance (di, 2);
ret = d_operator_name (di);
if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR)
{
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index 07e258fe58b..c1cfa1545ec 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -4682,3 +4682,10 @@ _ZZ3foovE8localVar__9_
_ZZ3foovE8localVar__12
_ZZ3foovE8localVar__12
+
+# PR 70182
+_Z1gI1AEv1SIXadsrT_onplEE
+void g<A>(S<&A::operator+>)
+
+_Z1gI1AEv1SIXadsrT_plEE
+void g<A>(S<&A::operator+>)