From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120501 invoked by alias); 14 Apr 2015 15:28:43 -0000 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 Received: (qmail 120483 invoked by uid 89); 14 Apr 2015 15:28:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 14 Apr 2015 15:28:42 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id AE9F63304A4 for ; Tue, 14 Apr 2015 15:28:40 +0000 (UTC) Received: from [10.10.116.43] ([10.10.116.43]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3EFSdfN023542 for ; Tue, 14 Apr 2015 11:28:40 -0400 Message-ID: <552D3224.8010202@redhat.com> Date: Tue, 14 Apr 2015 15:28:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/65721 (ICE with invalid using-declaration) Content-Type: multipart/mixed; boundary="------------000506050005060104080804" X-SW-Source: 2015-04/txt/msg00675.txt.bz2 This is a multi-part message in MIME format. --------------000506050005060104080804 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 337 The standard says that the nested-name-specifier in a using-declaration needs to name a base of the class. When we have dependent bases we can't be sure whether a particular type is a base or not, but we can certainly complain if name lookup find the current class rather than a base. Tested x86_64-pc-linux-gnu, applying to trunk. --------------000506050005060104080804 Content-Type: text/x-patch; name="65721.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="65721.patch" Content-length: 1215 commit d9ebf555e29b24e5fa3338471edbc9d922ae0edb Author: Jason Merrill Date: Sat Apr 11 10:41:22 2015 -0400 PR c++/65721 * name-lookup.c (do_class_using_decl): Complain about specifying the current class even if there are dependent bases. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index e3f7cca..9e4e0e3 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -3408,7 +3408,7 @@ do_class_using_decl (tree scope, tree name) tf_warning_or_error); if (b_kind < bk_proper_base) { - if (!bases_dependent_p) + if (!bases_dependent_p || b_kind == bk_same_type) { error_not_base_type (scope, current_class_type); return NULL_TREE; diff --git a/gcc/testsuite/g++.dg/lookup/using55.C b/gcc/testsuite/g++.dg/lookup/using55.C new file mode 100644 index 0000000..61098b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using55.C @@ -0,0 +1,19 @@ +// PR c++/65721 + +template +struct A { + typedef T D; +}; + +template +class B : public A { + using typename B::D; // { dg-error "not a base" } +public: + D echo(D x) { // { dg-error "D" } + return x; + } +}; + +int main() { + B b; +} --------------000506050005060104080804--