aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-02-17 17:51:25 -0500
committerJason Merrill <jason@gcc.gnu.org>2010-02-17 17:51:25 -0500
commitd29760adf92616716f04f958eacb9cceae2a0acf (patch)
treebdf901414d0b4aebba3124549aa355e020f55027
parentaf14c87be9d09cf9fc192f6db3edcbd441bae5ce (diff)
downloadgcc-d29760adf92616716f04f958eacb9cceae2a0acf.zip
gcc-d29760adf92616716f04f958eacb9cceae2a0acf.tar.gz
gcc-d29760adf92616716f04f958eacb9cceae2a0acf.tar.bz2
re PR c++/43079 (ICE with incompatible pointer-to-member-function as template parameter)
PR c++/43079 * pt.c (convert_nontype_argument): Change assert to test. From-SVN: r156839
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/ptrmem20.C16
4 files changed, 30 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4a7b125..40d7334 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2010-02-17 Jason Merrill <jason@redhat.com>
+
+ PR c++/43079
+ * pt.c (convert_nontype_argument): Change assert to test.
+
2010-02-16 Jason Merrill <jason@redhat.com>
* cp-gimplify.c (cp_gimplify_expr): Fix error recovery.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 43cd105..0165a7d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5128,12 +5128,13 @@ convert_nontype_argument (tree type, tree expr)
provide a superior diagnostic. */
if (!same_type_p (TREE_TYPE (expr), type))
{
- /* Make sure we are just one standard conversion off. */
- gcc_assert (can_convert (type, TREE_TYPE (expr)));
error ("%qE is not a valid template argument for type %qT "
"because it is of type %qT", expr, type,
TREE_TYPE (expr));
- inform (input_location, "standard conversions are not allowed in this context");
+ /* If we are just one standard conversion off, explain. */
+ if (can_convert (type, TREE_TYPE (expr)))
+ inform (input_location,
+ "standard conversions are not allowed in this context");
return NULL_TREE;
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e03a469..87e442e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-02-17 Jason Merrill <jason@redhat.com>
+
+ PR c++/43079
+ * g++.dg/template/ptrmem20.C: New.
+
2010-02-17 Uros Bizjak <ubizjak@gmail.com>
PR target/43103
diff --git a/gcc/testsuite/g++.dg/template/ptrmem20.C b/gcc/testsuite/g++.dg/template/ptrmem20.C
new file mode 100644
index 0000000..d98ef39
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ptrmem20.C
@@ -0,0 +1,16 @@
+// PR c++/43079
+
+struct A {};
+
+struct B
+{
+ void foo() const;
+ void foo();
+};
+
+template<void (A::*)()> void bar();
+
+void baz()
+{
+ bar<&B::foo>(); // { dg-error "not a valid template argument|no match" }
+}