aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2011-02-17 06:50:35 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2011-02-17 07:50:35 +0100
commit1770aeed11c064c75507eaca52a9e49234f9eff6 (patch)
treefc23bb02fc0bc9f23fa148ef548c987aee55d496 /gcc
parentfc2c5998f7027c07717c7237ff3d68e97bd7d067 (diff)
downloadgcc-1770aeed11c064c75507eaca52a9e49234f9eff6.zip
gcc-1770aeed11c064c75507eaca52a9e49234f9eff6.tar.gz
gcc-1770aeed11c064c75507eaca52a9e49234f9eff6.tar.bz2
re PR c++/47172 ([C++0x] cannot call member function without object)
Fix PR c++/47172 gcc/cp/ PR c++/47172 * pt.c (finish_call_expr): Consider a call expression that has a dependent "this" pointer as being dependent. Add comments. (dependent_type_p, type_dependent_expression_p): Update comments. gcc/testsuite/ * g++.dg/template/inherit6.C: New test. From-SVN: r170240
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/pt.c7
-rw-r--r--gcc/cp/semantics.c13
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/inherit6.C23
5 files changed, 52 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index dca9612..13de6bd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2011-02-11 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/47172
+ * pt.c (finish_call_expr): Consider a call expression that has a
+ dependent "this" pointer as being dependent. Add comments.
+ (dependent_type_p, type_dependent_expression_p): Update comments.
+
2011-02-16 Dodji Seketeli <dodji@redhat.com>
PR c++/47326
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index aa956c8..02b8d15 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -17921,7 +17921,7 @@ dependent_type_p_r (tree type)
}
/* Returns TRUE if TYPE is dependent, in the sense of
- [temp.dep.type]. */
+ [temp.dep.type]. Note that a NULL type is considered dependent. */
bool
dependent_type_p (tree type)
@@ -18193,7 +18193,10 @@ value_dependent_expression_p (tree expression)
}
/* Returns TRUE if the EXPRESSION is type-dependent, in the sense of
- [temp.dep.expr]. */
+ [temp.dep.expr]. Note that an expression with no type is
+ considered dependent. Other parts of the compiler arrange for an
+ expression with type-dependent subexpressions to have no type, so
+ this function doesn't have to be fully recursive. */
bool
type_dependent_expression_p (tree expression)
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 58a59ee..daa7280 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2028,8 +2028,19 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual,
if (processing_template_decl)
{
+ /* If the call expression is dependent, build a CALL_EXPR node
+ with no type; type_dependent_expression_p recognizes
+ expressions with no type as being dependent. */
if (type_dependent_expression_p (fn)
- || any_type_dependent_arguments_p (*args))
+ || any_type_dependent_arguments_p (*args)
+ /* For a non-static member function, we need to specifically
+ test the type dependency of the "this" pointer because it
+ 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)
+ && current_class_ref
+ && type_dependent_expression_p (current_class_ref)))
{
result = build_nt_call_vec (fn, *args);
KOENIG_LOOKUP_P (result) = koenig_p;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 19488e8..5275e99 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-02-11 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/47172
+ * g++.dg/template/inherit6.C: New test.
+
2011-02-16 Janus Weil <janus@gcc.gnu.org>
PR fortran/47745
diff --git a/gcc/testsuite/g++.dg/template/inherit6.C b/gcc/testsuite/g++.dg/template/inherit6.C
new file mode 100644
index 0000000..241a68e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/inherit6.C
@@ -0,0 +1,23 @@
+// Origin PR c++/47172
+// { dg-options "-std=c++0x" }
+// { dg-do compile }
+
+struct A
+{
+ int f() const;
+};
+
+template <class T>
+struct B : A { };
+
+template <class T>
+struct C : B<T>
+{
+ void g();
+};
+
+template <class T>
+void C<T>::g()
+{
+ A::f();
+}