aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-03-16 22:33:38 -0400
committerJason Merrill <jason@gcc.gnu.org>2013-03-16 22:33:38 -0400
commit6721db5d154364ab7f9bf7af62bc1a2f30313a39 (patch)
treec052c1f7043fd3af86bb9c7610458c725f6cf03c
parent720f3cb82d2c970e60b64bca0f6249db3f563de5 (diff)
downloadgcc-6721db5d154364ab7f9bf7af62bc1a2f30313a39.zip
gcc-6721db5d154364ab7f9bf7af62bc1a2f30313a39.tar.gz
gcc-6721db5d154364ab7f9bf7af62bc1a2f30313a39.tar.bz2
re PR c++/56095 (Crash casting function pointer as non-type template argument)
PR c++/56095 * class.c (resolve_address_of_overloaded_function): Accept a reference to function for target_type. (instantiate_type): Likewise. * pt.c (convert_nontype_argument): Pass it to convert_nontype_argument_function. From-SVN: r196722
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/class.c10
-rw-r--r--gcc/cp/pt.c2
3 files changed, 16 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a80043b..8aa3952 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2013-03-16 Jason Merrill <jason@redhat.com>
+
+ PR c++/56095
+ * class.c (resolve_address_of_overloaded_function): Accept a
+ reference to function for target_type.
+ (instantiate_type): Likewise.
+ * pt.c (convert_nontype_argument): Pass it to
+ convert_nontype_argument_function.
+
2013-03-16 Jakub Jelinek <jakub@redhat.com>
* tree.c (cp_tree_equal): Fix a pasto.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 746c29d..b48b353 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -7148,7 +7148,8 @@ resolve_address_of_overloaded_function (tree target_type,
gcc_assert (is_overloaded_fn (overload));
/* Check that the TARGET_TYPE is reasonable. */
- if (TYPE_PTRFN_P (target_type))
+ if (TYPE_PTRFN_P (target_type)
+ || TYPE_REFFN_P (target_type))
/* This is OK. */;
else if (TYPE_PTRMEMFUNC_P (target_type))
/* This is OK, too. */
@@ -7419,10 +7420,11 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags)
if (TREE_TYPE (rhs) != NULL_TREE && ! (type_unknown_p (rhs)))
{
- if (same_type_p (lhstype, TREE_TYPE (rhs)))
+ tree fntype = non_reference (lhstype);
+ if (same_type_p (fntype, TREE_TYPE (rhs)))
return rhs;
if (flag_ms_extensions
- && TYPE_PTRMEMFUNC_P (lhstype)
+ && TYPE_PTRMEMFUNC_P (fntype)
&& !TYPE_PTRMEMFUNC_P (TREE_TYPE (rhs)))
/* Microsoft allows `A::f' to be resolved to a
pointer-to-member. */
@@ -7431,7 +7433,7 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags)
{
if (flags & tf_error)
error ("cannot convert %qE from type %qT to type %qT",
- rhs, TREE_TYPE (rhs), lhstype);
+ rhs, TREE_TYPE (rhs), fntype);
return error_mark_node;
}
}
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index eb9fc7f..36175ca 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5788,7 +5788,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
return NULL_TREE;
}
- expr = convert_nontype_argument_function (TREE_TYPE (type), expr);
+ expr = convert_nontype_argument_function (type, expr);
if (!expr || expr == error_mark_node)
return expr;