aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-04-03 20:14:00 -0400
committerJason Merrill <jason@gcc.gnu.org>2013-04-03 20:14:00 -0400
commit0861bec80a0d8ff9aae4ed031e7f6869d37a3af2 (patch)
treedb5ffa9a448dd27fa04e384e2492f7f9d32e6d9e /gcc
parent4e8567986360dd629df5e60cfe881ac0916e45d0 (diff)
downloadgcc-0861bec80a0d8ff9aae4ed031e7f6869d37a3af2.zip
gcc-0861bec80a0d8ff9aae4ed031e7f6869d37a3af2.tar.gz
gcc-0861bec80a0d8ff9aae4ed031e7f6869d37a3af2.tar.bz2
cp-demangle.c (cplus_demangle_type): Fix function quals.
libiberty/ * cp-demangle.c (cplus_demangle_type): Fix function quals. (d_pointer_to_member_type): Simplify. gcc/cp/ * mangle.c (write_type): When writing a function type with function-cv-quals, don't add the unqualified type as a substitution candidate. From-SVN: r197460
Diffstat (limited to 'gcc')
-rw-r--r--gcc/common.opt5
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/mangle.c12
-rw-r--r--gcc/testsuite/g++.dg/abi/mangle62.C11
-rw-r--r--gcc/testsuite/g++.dg/abi/mangle62a.C11
5 files changed, 43 insertions, 2 deletions
diff --git a/gcc/common.opt b/gcc/common.opt
index bdbd3b6c..e02e7ed 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -792,6 +792,11 @@ Driver Undocumented
; 7: The version of the ABI that treats nullptr_t as a builtin type and
; corrects the mangling of lambdas in default argument scope.
; First selectable in G++ 4.8.
+;
+; 8: The version of the ABI that corrects the substitution behavior of
+; function types with function-cv-qualifiers.
+; First selectable in G++ 4.9.
+;
; Additional positive integers will be assigned as new versions of
; the ABI become the default version of the ABI.
fabi-version=
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9020dad..ef38bc2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2013-04-03 Jason Merrill <jason@redhat.com>
+
+ * mangle.c (write_type): When writing a function type with
+ function-cv-quals, don't add the unqualified type as a
+ substitution candidate.
+
2013-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/56815
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 4e68c51..83c3e62 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -1897,8 +1897,16 @@ write_type (tree type)
tree t = TYPE_MAIN_VARIANT (type);
if (TREE_CODE (t) == FUNCTION_TYPE
|| TREE_CODE (t) == METHOD_TYPE)
- t = build_ref_qualified_type (t, type_memfn_rqual (type));
- write_type (t);
+ {
+ t = build_ref_qualified_type (t, type_memfn_rqual (type));
+ if (abi_version_at_least (8))
+ /* Avoid adding the unqualified function type as a substitution. */
+ write_function_type (t);
+ else
+ write_type (t);
+ }
+ else
+ write_type (t);
}
else if (TREE_CODE (type) == ARRAY_TYPE)
/* It is important not to use the TYPE_MAIN_VARIANT of TYPE here
diff --git a/gcc/testsuite/g++.dg/abi/mangle62.C b/gcc/testsuite/g++.dg/abi/mangle62.C
new file mode 100644
index 0000000..6dbfd78
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/mangle62.C
@@ -0,0 +1,11 @@
+// Before v8, we mistakenly treated an unqualified function type
+// as a substitution candidate for a function type with function-cv-quals.
+// Test for the conformant behavior.
+
+// { dg-options -fabi-version=0 }
+
+template <class T, class U> struct A { };
+// { dg-final { scan-assembler "_Z1fP1AIKFvvEFvvEE" } }
+void f (A<void()const, void()> *){}
+// { dg-final { scan-assembler "_Z1gP1AIFvvEKFvvEE" } }
+void g (A<void(), void()const> *){}
diff --git a/gcc/testsuite/g++.dg/abi/mangle62a.C b/gcc/testsuite/g++.dg/abi/mangle62a.C
new file mode 100644
index 0000000..fca1cb6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/mangle62a.C
@@ -0,0 +1,11 @@
+// Before v8, we mistakenly treated an unqualified function type
+// as a substitution candidate for a function type with function-cv-quals.
+// Test for that for backward compatibility.
+
+// { dg-options -fabi-version=7 }
+
+template <class T, class U> struct A { };
+// { dg-final { scan-assembler "_Z1fP1AIKFvvES0_E" } }
+void f (A<void()const, void()> *){}
+// { dg-final { scan-assembler "_Z1gP1AIFvvEKS0_E" } }
+void g (A<void(), void()const> *){}