Commit 9ae58faf by Nathan Sidwell Committed by Nathan Sidwell

re PR c++/9437 (template function parameter `T*' shouldn't match pointers to members)

cp:
	PR c++/9437
	* pt.c (unify): Don't unify '*T' with 'U C::*'.
testsuite:
	PR c++/9437
	* g++.dg/template/unify4.C: New test.

From-SVN: r62070
parent cf0150b9
2003-01-28 Nathan Sidwell <nathan@codesourcery.com> 2003-01-28 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9437
* pt.c (unify): Don't unify '*T' with 'U C::*'.
PR c++/3902 PR c++/3902
* parser.c (cp_parser_decl_specifier_seq): Cannot have constructor * parser.c (cp_parser_decl_specifier_seq): Cannot have constructor
inside a declarator. inside a declarator.
......
...@@ -9447,6 +9447,12 @@ unify (tparms, targs, parm, arg, strict) ...@@ -9447,6 +9447,12 @@ unify (tparms, targs, parm, arg, strict)
} }
else else
{ {
/* If ARG is an offset type, we're trying to unify '*T' with
'U C::*', which is ill-formed. See the comment in the
POINTER_TYPE case about this ugliness. */
if (TREE_CODE (arg) == OFFSET_TYPE)
return 1;
/* If PARM is `const T' and ARG is only `int', we don't have /* If PARM is `const T' and ARG is only `int', we don't have
a match unless we are allowing additional qualification. a match unless we are allowing additional qualification.
If ARG is `const int' and PARM is just `T' that's OK; If ARG is `const int' and PARM is just `T' that's OK;
......
2003-01-29 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9437
* g++.dg/template/unify4.C: New test.
2003-01-28 Richard Sandiford <rsandifo@redhat.com> 2003-01-28 Richard Sandiford <rsandifo@redhat.com>
* gcc.c-torture/execute/20030128-1.c: New test. * gcc.c-torture/execute/20030128-1.c: New test.
......
// { dg-do compile }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 28 Jan 2003 <nathan@codesourcery.com>
// PR 9437. We'd unify 'T *' with 'U C::*', which is obviously broken
struct X
{
template <typename T>
operator T* () const { return static_cast<T*> (0); }
} null;
struct A { int i; };
static void f (int A::* pmi) { }
int main () { f (null); } // { dg-error "cannot convert" "" }
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