Hi,

the issue here is that... I'm not sure the bug report is valid ;) Seriously, *if* we think it is, must be fixable with a moderate effort. Here Jason fixed the closely related c++/53721:

    http://gcc.gnu.org/ml/gcc-patches/2013-04/msg01445.html

and tweaking a bit more the check would allow this variant too, with outer pointing to the enclosing S:

struct S
{
    int foo();

    struct nested
    {
        S* outer;

        auto bar() -> decltype(outer->foo());
    };
};


but I'm not sure it's valid code: for example clang accepts it, icc doesn't. If it is, something along the lines of the attached (with at least an improved comment: we want to say something like pointer to this *or* to enclosing class) works for the testcase (and a few positive and negative variants) and lightly tested on x86_64-linux.

Thanks!
Paolo.

/////////////////////////



Index: parser.c
===================================================================
--- parser.c    (revision 201558)
+++ parser.c    (working copy)
@@ -6294,8 +6294,10 @@ cp_parser_postfix_dot_deref_expression (cp_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 (postfix_expression != current_class_ref
-              && !(processing_template_decl && scope == current_class_type))
+      else if (!(processing_template_decl && scope == current_class_type)
+              && (!current_class_type || !CLASS_TYPE_P (scope)
+                  || (common_enclosing_class (scope, current_class_type)
+                      != scope)))
        scope = complete_type_or_else (scope, NULL_TREE);
       /* Let the name lookup machinery know that we are processing a
         class member access expression.  */

Reply via email to