* [C++ PATCH] Issue errors on invalid use of non-static memfn in build_new_op (PR c++/29225)
@ 2007-11-12 18:05 Jakub Jelinek
2007-11-12 23:36 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2007-11-12 18:05 UTC (permalink / raw)
To: Jason Merrill, Mark Mitchell; +Cc: gcc-patches
Hi!
On the following invalid testcase g++ doesn't emit diagnostics and
crashes at gimplification time on unexpected trees in fn body.
Most of the functions that call build_over_call call resolve_args
to ensure the arguments are sane (and that calls
invalid_nonstatic_memfn_p). But build_new_op only checks for
error_operand_p early (e.g. because code can be CALL_EXPR in which
case that is valid for arg1) and doesn't do any checking when it finds
an operator it wants to use.
Fixed by calling resolve_args before the build_over_call.
Regtested on x86_64-linux, ok for trunk?
2007-11-12 Jakub Jelinek <jakub@redhat.com>
PR c++/29225
* call.c (build_new_op): Call resolve_args before calling
build_over_call.
* g++.dg/template/crash72.C: New test.
--- gcc/cp/call.c.jj 2007-11-07 20:25:28.000000000 +0100
+++ gcc/cp/call.c 2007-11-12 17:15:12.000000000 +0100
@@ -3918,7 +3918,10 @@ build_new_op (enum tree_code code, int f
if (overloaded_p)
*overloaded_p = true;
- result = build_over_call (cand, LOOKUP_NORMAL);
+ if (resolve_args (arglist) == error_mark_node)
+ result = error_mark_node;
+ else
+ result = build_over_call (cand, LOOKUP_NORMAL);
}
else
{
--- gcc/testsuite/g++.dg/template/crash72.C.jj 2007-11-12 17:25:09.000000000 +0100
+++ gcc/testsuite/g++.dg/template/crash72.C 2007-11-12 17:21:56.000000000 +0100
@@ -0,0 +1,25 @@
+// PR c++/29225
+// { dg-do compile }
+
+template <typename L, typename R> bool operator< (L x, R y);
+struct T { int t (); };
+class S {};
+
+struct U
+{
+ typedef int (T::* M) ();
+ M m;
+
+ bool operator() (S &x)
+ {
+ T a;
+ return (a.*m) < x; // { dg-error "invalid use of non-static member" }
+ }
+};
+
+void foo (S &x)
+{
+ U m;
+ m.m = &T::t;
+ m (x);
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ PATCH] Issue errors on invalid use of non-static memfn in build_new_op (PR c++/29225)
2007-11-12 18:05 [C++ PATCH] Issue errors on invalid use of non-static memfn in build_new_op (PR c++/29225) Jakub Jelinek
@ 2007-11-12 23:36 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2007-11-12 23:36 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Mark Mitchell, gcc-patches
OK.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-11-12 22:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-12 18:05 [C++ PATCH] Issue errors on invalid use of non-static memfn in build_new_op (PR c++/29225) Jakub Jelinek
2007-11-12 23:36 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).