public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR c++/48656
@ 2011-04-28 15:42 Dodji Seketeli
  2011-04-28 15:53 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Dodji Seketeli @ 2011-04-28 15:42 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC Patches

Hello,

At the moment G++ considers a call expression involving a member
function which implicit 'this' pointer is type dependant, as being a
type dependent expression (PR c++/47172).  The problem in this PR is
that it fails to recognize a BASELINK node as being a member function.

As a result, the call expression A::f() in the example of the patch
below is not considered type dependent and so finish_expr_stmt wrongly
makes the call expression take the code path reserved for non-dependent
expressions.

The patch below adds the BASELINK case to the relevant test, but I am
not sure if I am missing other cases of nodes that could represent a
member function call expression.

I ran a regression test with this patch (with make check) without
bootstrap on x86_64-unknown-linux-gnu and I am currently running a
full bootstrap & regression test against trunk.

OK to commit to trunk and 4.6 if the test passes?

gcc/cp/

	* semantics.c (finish_call_expr): Don't forget BASELINK nodes when
	considering call expressions involving a member function.

gcc/testsuite/

	* gcc/testsuite/g++.dg/template/inherit7.C: New test case.
---
 gcc/cp/semantics.c                       |    3 ++-
 gcc/testsuite/g++.dg/template/inherit7.C |   21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/template/inherit7.C

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 16fabb8..5486dd3 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2039,7 +2039,8 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual,
 	     is not included in *ARGS even though it is considered to
 	     be part of the list of arguments.  Note that this is
 	     related to CWG issues 515 and 1005.  */
-	  || ((TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE)
+	  || (((TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE)
+	       || BASELINK_P (fn))
 	      && current_class_ref
 	      && type_dependent_expression_p (current_class_ref)))
 	{
diff --git a/gcc/testsuite/g++.dg/template/inherit7.C b/gcc/testsuite/g++.dg/template/inherit7.C
new file mode 100644
index 0000000..67afbca
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/inherit7.C
@@ -0,0 +1,21 @@
+// Origin: PR c++/48656
+// { dg-options "-std=c++0x" }
+// { dg-do compile }
+
+struct A {
+ int f();
+ int f(int);
+};
+
+template <typename> struct B : A
+{
+};
+
+template <typename T> struct C : B<T>
+{
+    void
+    g()
+    {
+        A::f();
+    }
+};
-- 
		Dodji

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix PR c++/48656
  2011-04-28 15:42 [PATCH] Fix PR c++/48656 Dodji Seketeli
@ 2011-04-28 15:53 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2011-04-28 15:53 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: GCC Patches

OK.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-28 15:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-28 15:42 [PATCH] Fix PR c++/48656 Dodji Seketeli
2011-04-28 15:53 ` 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).