We were already trying to support the rule that *this doesn't need to be
complete for class member access, but we were comparing the wrong thing
to current_class_ref.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 460a34462cd0dd2787e1ffddf4b08d1c36ff5557
Author: Jason Merrill <ja...@redhat.com>
Date: Wed Apr 24 11:30:03 2013 -0400
PR c++/53721
* parser.c (cp_parser_postfix_dot_deref_expression): Fix thinko.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index cb26292..2239a07 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -6155,7 +6155,7 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
/* Unlike the object expression in other contexts, *this is not
required to be of complete type for purposes of class member
access (5.2.5) outside the member function body. */
- else if (scope != current_class_ref
+ else if (postfix_expression != current_class_ref
&& !(processing_template_decl && scope == current_class_type))
scope = complete_type_or_else (scope, NULL_TREE);
/* Let the name lookup machinery know that we are processing a
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype51.C b/gcc/testsuite/g++.dg/cpp0x/decltype51.C
new file mode 100644
index 0000000..9ab4146
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype51.C
@@ -0,0 +1,10 @@
+// PR c++/53721
+// { dg-require-effective-target c++11 }
+
+struct A
+{
+ void f() {};
+ auto g() -> decltype(this->f())
+ {
+ }
+};