Message ID | 52029D61.2050107@oracle.com |
---|---|
State | New |
Headers | show |
On 08/07/2013 03:17 PM, Paolo Carlini wrote: > 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. The rule that allows use of *this is pretty specific: 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. That doesn't seem to allow the use of *outer. Jason
Hi, On 08/07/2013 09:52 PM, Jason Merrill wrote: > The rule that allows use of *this is pretty specific: > > 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. > > That doesn't seem to allow the use of *outer. Ok. I'm closing the report as invalid. 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. */