Commit a0685b73 by Jason Merrill Committed by Jason Merrill

* typeck.c (merge_types): Preserve memfn quals.

From-SVN: r159598
parent 93e1ddcf
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.
......
......@@ -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;
}
......
2010-05-19 Jason Merrill <jason@redhat.com>
* g++.dg/parse/fn-typedef2.C: New.
* g++.dg/other/cv_func.C: Don't expect errors about cv-qualified
function type.
......
// Test that merge_types preserves fn cv-quals.
typedef void ft() const;
typedef void V;
typedef V ft() const;
ft f; // { dg-error "qualified" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment