From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31648 invoked by alias); 6 Dec 2012 19:43:50 -0000 Received: (qmail 31640 invoked by uid 22791); 6 Dec 2012 19:43:49 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 06 Dec 2012 19:43:37 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qB6JhaUT011084 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Dec 2012 14:43:36 -0500 Received: from [10.3.113.18] ([10.3.113.18]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qB6JhZuX026029 for ; Thu, 6 Dec 2012 14:43:36 -0500 Message-ID: <50C0F567.5050505@redhat.com> Date: Thu, 06 Dec 2012 19:43:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/54913 (error with static reference member and templates) Content-Type: multipart/mixed; boundary="------------070704090201080201020108" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg00426.txt.bz2 This is a multi-part message in MIME format. --------------070704090201080201020108 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 368 We build up a SCOPE_REF to remember that we saw a qualified-id in a template. We also want to convert_from_reference so that a use of a reference member decays to a non-reference. But we were doing them in the wrong order, so that the second operand of the SCOPE_REF was an INDIRECT_REF, which doesn't make sense. Tested x86_64-pc-linux-gnu, applying to trunk. --------------070704090201080201020108 Content-Type: text/x-patch; name="54913.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="54913.patch" Content-length: 1326 commit fde00723eeea410df8f677fe6753c68e7277796d Author: Jason Merrill Date: Thu Dec 6 10:31:52 2012 -0500 PR c++/54913 * semantics.c (finish_qualified_id_expr): convert_from_reference after building a SCOPE_REF. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 53e849a..6c168e4 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1778,8 +1778,6 @@ finish_qualified_id_expr (tree qualifying_class, ; else { - expr = convert_from_reference (expr); - /* In a template, return a SCOPE_REF for most qualified-ids so that we can check access at instantiation time. But if we're looking at a member of the current instantiation, we @@ -1790,6 +1788,8 @@ finish_qualified_id_expr (tree qualifying_class, expr = build_qualified_name (TREE_TYPE (expr), qualifying_class, expr, template_p); + + expr = convert_from_reference (expr); } return expr; diff --git a/gcc/testsuite/g++.dg/template/qualified-id6.C b/gcc/testsuite/g++.dg/template/qualified-id6.C new file mode 100644 index 0000000..83be874 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/qualified-id6.C @@ -0,0 +1,14 @@ +// PR c++/54913 + +struct E +{ + static const int& e; +}; + +template +struct R +{ + R() { E::e; } +}; + +R r; --------------070704090201080201020108--