From patchwork Wed Aug 7 19:17:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 265594 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 914962C0097 for ; Thu, 8 Aug 2013 05:18:12 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=wi02DjqpZ6ajO4Tn5pgV6tzE+V/vSDmICW87oMEvqCG YhNMf/7Ss20Xndx7ZjBfQb1XL/I14byvWvLRYTNONB1daClTSRXa0RbHTLqMxhFq d+hZgi+NukhP4IhJ0ERKpbbHMcyTgCAeHz/eEm+eN52I0D257RYcIsWIWnfkAykc = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=sfClIgsGHIXOXLyWuJiA7hGGHCU=; b=UbI80ktS12ZdJqYED cf0H+JDUvuet0U1O27J3SrjnB4wDlGcvEUGAyLBdXYcYNtIgdfbzuJagtOMn6cwA mAwCb/vCjLSOsr+V/kHi1gHGR//ZWtUumv0ScYpN7x9FvtZOiLPwBaLhQaLONjmt Dubc55d/x4HW/rq2KXO2TSshVo= Received: (qmail 26442 invoked by alias); 7 Aug 2013 19:18:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 26416 invoked by uid 89); 7 Aug 2013 19:18:05 -0000 X-Spam-SWARE-Status: No, score=-4.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_YE, RDNS_NONE, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from Unknown (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 07 Aug 2013 19:18:05 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r77JHuGx015837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 Aug 2013 19:17:57 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r77JHuqT013608 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 7 Aug 2013 19:17:56 GMT Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r77JHtdh013599; Wed, 7 Aug 2013 19:17:55 GMT Received: from poldo4.casa (/79.36.197.175) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 07 Aug 2013 12:17:55 -0700 Message-ID: <52029D61.2050107@oracle.com> Date: Wed, 07 Aug 2013 21:17:53 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch / RFC] PR 54864 X-Virus-Found: No 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. */