From f62cd40949d0219d9c2c6e24afb0377fcde9d0e3 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Thu, 28 Apr 2011 18:08:43 +0000 Subject: [PATCH] re PR c++/48656 ([C++0x] cannot call member function without object) Fix PR c++/48656 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. From-SVN: r173123 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/inherit7.C | 21 +++++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/inherit7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 163bee3c1a0..6b6d81bd26e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-04-28 Dodji Seketeli + + PR c++/48656 + * semantics.c (finish_call_expr): Don't forget BASELINK nodes when + considering call expressions involving a member function. + 2011-04-28 Paolo Carlini PR c++/48530 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c6364120fe5..722e57fe528 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/ChangeLog b/gcc/testsuite/ChangeLog index 7f3804b98cb..b0d5e1c6f6c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-04-28 Dodji Seketeli + + PR c++/48656 + * g++.dg/template/inherit7.C: New test case. + 2011-04-28 Richard Guenther PR tree-optimization/40052 diff --git a/gcc/testsuite/g++.dg/template/inherit7.C b/gcc/testsuite/g++.dg/template/inherit7.C new file mode 100644 index 00000000000..67afbca6bf0 --- /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 struct B : A +{ +}; + +template struct C : B +{ + void + g() + { + A::f(); + } +}; -- 2.30.2