diff mbox

Fix PR c++/48656

Message ID m3mxjaxvc8.fsf@redhat.com
State New
Headers show

Commit Message

Dodji Seketeli April 28, 2011, 3:13 p.m. UTC
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

Comments

Jason Merrill April 28, 2011, 3:42 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

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();
+    }
+};