aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-05-19 17:02:16 -0400
committerJason Merrill <jason@gcc.gnu.org>2010-05-19 17:02:16 -0400
commita0685b7311e693f8b0ed709ae0727af294a6a72b (patch)
tree1f4e82ff0763474f40d38c31b992865c037a7f04 /gcc/cp
parent93e1ddcf9c8f4b8b64d0e53bd4a4f306eb70bdd4 (diff)
downloadgcc-a0685b7311e693f8b0ed709ae0727af294a6a72b.zip
gcc-a0685b7311e693f8b0ed709ae0727af294a6a72b.tar.gz
gcc-a0685b7311e693f8b0ed709ae0727af294a6a72b.tar.bz2
* typeck.c (merge_types): Preserve memfn quals.
From-SVN: r159598
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog2
-rw-r--r--gcc/cp/typeck.c27
2 files changed, 18 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 26eaafc..6dd97bb 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,7 @@
2010-05-19 Jason Merrill <jason@redhat.com>
+ * typeck.c (merge_types): Preserve memfn quals.
+
* decl.c (grokdeclarator): Don't check quals on fn type.
* typeck.c (cp_apply_type_quals_to_decl): Likewise.
* tree.c (cp_build_qualified_type_real): Simplify qualifier checking.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 44d7ab1..a46b218 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -810,6 +810,7 @@ merge_types (tree t1, tree t2)
tree valtype = merge_types (TREE_TYPE (t1), TREE_TYPE (t2));
tree p1 = TYPE_ARG_TYPES (t1);
tree p2 = TYPE_ARG_TYPES (t2);
+ tree parms;
tree rval, raises;
/* Save space: see if the result is identical to one of the args. */
@@ -821,21 +822,25 @@ merge_types (tree t1, tree t2)
/* Simple way if one arg fails to specify argument types. */
if (p1 == NULL_TREE || TREE_VALUE (p1) == void_type_node)
{
- rval = build_function_type (valtype, p2);
- if ((raises = TYPE_RAISES_EXCEPTIONS (t2)))
- rval = build_exception_variant (rval, raises);
- return cp_build_type_attribute_variant (rval, attributes);
+ parms = p2;
+ raises = TYPE_RAISES_EXCEPTIONS (t2);
}
- raises = TYPE_RAISES_EXCEPTIONS (t1);
- if (p2 == NULL_TREE || TREE_VALUE (p2) == void_type_node)
+ else if (p2 == NULL_TREE || TREE_VALUE (p2) == void_type_node)
{
- rval = build_function_type (valtype, p1);
- if (raises)
- rval = build_exception_variant (rval, raises);
- return cp_build_type_attribute_variant (rval, attributes);
+ parms = p1;
+ raises = TYPE_RAISES_EXCEPTIONS (t1);
+ }
+ else
+ {
+ parms = commonparms (p1, p2);
+ /* In cases where we're merging a real declaration with a
+ built-in declaration, t1 is the real one. */
+ raises = TYPE_RAISES_EXCEPTIONS (t1);
}
- rval = build_function_type (valtype, commonparms (p1, p2));
+ rval = build_function_type (valtype, parms);
+ gcc_assert (type_memfn_quals (t1) == type_memfn_quals (t2));
+ rval = apply_memfn_quals (rval, type_memfn_quals (t1));
t1 = build_exception_variant (rval, raises);
break;
}