aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2003-01-29 11:35:33 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2003-01-29 11:35:33 +0000
commit9ae58faf6f8865c3244528632e250a7e70103085 (patch)
tree47c1b07e30f01fecc155ea7422312bf32ba2e12e /gcc
parentcf0150b9952445449513cbdaca51993c7dac64d4 (diff)
downloadgcc-9ae58faf6f8865c3244528632e250a7e70103085.zip
gcc-9ae58faf6f8865c3244528632e250a7e70103085.tar.gz
gcc-9ae58faf6f8865c3244528632e250a7e70103085.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/pt.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/unify4.C18
4 files changed, 32 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 09445a06..d84824d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2003-01-28 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/9437
+ * pt.c (unify): Don't unify '*T' with 'U C::*'.
+
PR c++/3902
* parser.c (cp_parser_decl_specifier_seq): Cannot have constructor
inside a declarator.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 21d3536..b3b8106 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9447,6 +9447,12 @@ unify (tparms, targs, parm, arg, strict)
}
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
a match unless we are allowing additional qualification.
If ARG is `const int' and PARM is just `T' that's OK;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9e5ea48..6c16728 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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>
* gcc.c-torture/execute/20030128-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/unify4.C b/gcc/testsuite/g++.dg/template/unify4.C
new file mode 100644
index 0000000..19d9f3a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/unify4.C
@@ -0,0 +1,18 @@
+// { 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" "" }