Commit c4bcc71f by Jason Merrill Committed by Jason Merrill

re PR c++/40342 (ambiguous overload not diagnosed)

	PR c++/40342
	* decl.c (decls_match): Check DECL_TI_TEMPLATE too.
	* class.c (resolve_address_of_overloaded_function): Fix typo.

From-SVN: r148910
parent ead1eb1d
2009-06-24 Jason Merrill <jason@redhat.com>
PR c++/40342
* decl.c (decls_match): Check DECL_TI_TEMPLATE too.
* class.c (resolve_address_of_overloaded_function): Fix typo.
2009-06-18 Aldy Hernandez <aldyh@redhat.com> 2009-06-18 Aldy Hernandez <aldyh@redhat.com>
* class.c (get_vtable_decl): Replace finish_decl with cp_finish_decl. * class.c (get_vtable_decl): Replace finish_decl with cp_finish_decl.
......
...@@ -6185,7 +6185,7 @@ resolve_address_of_overloaded_function (tree target_type, ...@@ -6185,7 +6185,7 @@ resolve_address_of_overloaded_function (tree target_type,
fn = TREE_PURPOSE (matches); fn = TREE_PURPOSE (matches);
for (match = TREE_CHAIN (matches); match; match = TREE_CHAIN (match)) for (match = TREE_CHAIN (matches); match; match = TREE_CHAIN (match))
if (!decls_match (fn, TREE_PURPOSE (matches))) if (!decls_match (fn, TREE_PURPOSE (match)))
break; break;
if (match) if (match)
......
...@@ -916,6 +916,17 @@ decls_match (tree newdecl, tree olddecl) ...@@ -916,6 +916,17 @@ decls_match (tree newdecl, tree olddecl)
tree p1 = TYPE_ARG_TYPES (f1); tree p1 = TYPE_ARG_TYPES (f1);
tree p2 = TYPE_ARG_TYPES (f2); tree p2 = TYPE_ARG_TYPES (f2);
/* Specializations of different templates are different functions
even if they have the same type. */
tree t1 = (DECL_USE_TEMPLATE (newdecl)
? DECL_TI_TEMPLATE (newdecl)
: NULL_TREE);
tree t2 = (DECL_USE_TEMPLATE (olddecl)
? DECL_TI_TEMPLATE (olddecl)
: NULL_TREE);
if (t1 != t2)
return 0;
if (CP_DECL_CONTEXT (newdecl) != CP_DECL_CONTEXT (olddecl) if (CP_DECL_CONTEXT (newdecl) != CP_DECL_CONTEXT (olddecl)
&& ! (DECL_EXTERN_C_P (newdecl) && ! (DECL_EXTERN_C_P (newdecl)
&& DECL_EXTERN_C_P (olddecl))) && DECL_EXTERN_C_P (olddecl)))
......
2009-06-24 Jason Merrill <jason@redhat.com>
PR c++/40342
* g++.dg/template/overload10.C: New.
2009-06-24 Janus Weil <janus@gcc.gnu.org> 2009-06-24 Janus Weil <janus@gcc.gnu.org>
PR fortran/40427 PR fortran/40427
......
// PR c++40342
template <typename T1, typename T2> int f(T1 *, const T2 *); // { dg-error "" }
template <typename T1, typename T2> int f(const T1 *, T2 *); // { dg-error "" }
int (*p)(const int *, const int *) = f; // { dg-error "ambiguous" }
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