From patchwork Fri Nov 18 10:18:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fabien_Ch=C3=AAne?= X-Patchwork-Id: 126377 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]) by ozlabs.org (Postfix) with SMTP id D6E48B7258 for ; Fri, 18 Nov 2011 21:18:28 +1100 (EST) Received: (qmail 7773 invoked by alias); 18 Nov 2011 10:18:25 -0000 Received: (qmail 7742 invoked by uid 22791); 18 Nov 2011 10:18:24 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Nov 2011 10:18:09 +0000 Received: by ghy10 with SMTP id 10so389457ghy.20 for ; Fri, 18 Nov 2011 02:18:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.176.5 with SMTP id bc5mr900383qab.52.1321611488149; Fri, 18 Nov 2011 02:18:08 -0800 (PST) Received: by 10.229.215.204 with HTTP; Fri, 18 Nov 2011 02:18:08 -0800 (PST) Date: Fri, 18 Nov 2011 11:18:08 +0100 Message-ID: Subject: [C++ Patch] PR c++/51188 From: =?ISO-8859-1?Q?Fabien_Ch=EAne?= To: Jason Merrill Cc: GCC Patches X-IsSubscribed: yes 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 Hi, As discussed in the audit trail, here is a patch that fixes this PR and all its duplicates. Tested x86_64-unknown-linux-gnu without regressions. OK to commit ? gcc/testsuite/ChangeLog 2011-11-18 Fabien ChĂȘne PR c++/51188 * g++.dg/lookup/using46.C: New. * g++.dg/lookup/using47.C: New. * g++.dg/lookup/using48.C: New. * g++.dg/lookup/using49.C: New. * g++.dg/lookup/using50.C: New. gcc/cp/ChangeLog 2011-11-18 Fabien ChĂȘne PR c++/51188 * search.c (lookup_field_1): Handle USING_DECLs for the storted case. Index: gcc/testsuite/g++.dg/debug/using6.C =================================================================== --- gcc/testsuite/g++.dg/debug/using6.C (revision 0) +++ gcc/testsuite/g++.dg/debug/using6.C (revision 0) @@ -0,0 +1,22 @@ +// PR c++/51189 +// { dg-do compile } + +struct A +{ + int i1, i2, i3, i4, i5, i6; +}; + +struct B : A +{ + using A::i1; + using A::i2; + using A::i3; + using A::i4; + using A::i5; + using A::i6; +}; + +struct C : B +{ + using B::i1; +}; Index: gcc/testsuite/g++.dg/lookup/using49.C =================================================================== --- gcc/testsuite/g++.dg/lookup/using49.C (revision 0) +++ gcc/testsuite/g++.dg/lookup/using49.C (revision 0) @@ -0,0 +1,20 @@ +// PR c++/51188 +// { dg-do compile } + +#include +class XBase { +public: + virtual ~XBase() = 0; + enum ImpMode { Imp1, Imp2, Imp3 }; +}; +class X : public XBase { + class XBlock {}; + using XBase::ImpMode; + using XBase::Imp3; + using XBase::Imp1; + using XBase::Imp2; + int _XBlocked; + std::pair getImp(void) const { + return (std::make_pair(0, static_cast(X::Imp1))); + } +}; Index: gcc/testsuite/g++.dg/lookup/using46.C =================================================================== --- gcc/testsuite/g++.dg/lookup/using46.C (revision 0) +++ gcc/testsuite/g++.dg/lookup/using46.C (revision 0) @@ -0,0 +1,65 @@ +// PR c++/51141 +// { dg-do compile } +// { dg-options "-fpermissive -w -Werror" } + +typedef int size_t; +template < size_t, size_t > struct AlignedBuffer; +template < size_t size > struct AlignedBuffer + < size, 8 > { +}; + +template < typename > class VectorBufferBase +{ +public: + allocateBuffer (size_t) { + } + buffer () { + } + *m_buffer; + size_t m_capacity; +}; + +template < typename T, size_t > class VectorBuffer:VectorBufferBase < T > +{ + typedef VectorBufferBase < T > Base; + +public: + VectorBuffer () { + } + allocateBuffer (size_t) { + m_capacity = 0; + } + Base::buffer; + Base::m_buffer; + Base::m_capacity; + size_t m_inlineBufferSize; + + AlignedBuffer < 0, __alignof__ (T) > m_inlineBuffer; +}; + +template < typename T, size_t > class Vector +{ + typedef VectorBuffer < T, + 0 > Buffer; +public: + void shrinkCapacity (size_t); + + clear () { + shrinkCapacity (0); + } + Buffer m_buffer; +}; + +template < typename T, size_t inlineCapacity > void Vector < T, + inlineCapacity >::shrinkCapacity (size_t) +{ + m_buffer.allocateBuffer (0); +} + +struct PatternDisjunction; +struct YarrPattern { + reset () { + m_disjunctions.clear (); + } + Vector < PatternDisjunction *, 0 > m_disjunctions; +}; Index: gcc/testsuite/g++.dg/lookup/using47.C =================================================================== --- gcc/testsuite/g++.dg/lookup/using47.C (revision 0) +++ gcc/testsuite/g++.dg/lookup/using47.C (revision 0) @@ -0,0 +1,29 @@ +// PR c++/51152 +// { dg-do compile } + +struct A +{ + int a; +}; + +struct B +{ + int b1; + int b2; + A b3; +}; + +struct C : B +{ + typedef int R; + typedef int S; + typedef int T; + using B::b1; + using B::b2; + using B::b3; + void f() + { + b3.a; + b3.~A(); + } +}; Index: gcc/testsuite/g++.dg/lookup/using48.C =================================================================== --- gcc/testsuite/g++.dg/lookup/using48.C (revision 0) +++ gcc/testsuite/g++.dg/lookup/using48.C (revision 0) @@ -0,0 +1,23 @@ +// PR c++/51190 +// { dg-do compile } + +struct A +{ + int i; +}; + +template struct B +{ + A* p; +}; + +template struct C : B +{ + using B::p; + + C() { p->i; } + + int i1, i2, i3, i4, i5; +}; + +C c; Index: gcc/cp/search.c =================================================================== --- gcc/cp/search.c (revision 181386) +++ gcc/cp/search.c (working copy) @@ -436,6 +436,14 @@ lookup_field_1 (tree type, tree name, bo field = fields[i++]; while (i < hi && DECL_NAME (fields[i]) == name); } + + if (field) + { + field = strip_using_decl (field); + if (is_overloaded_fn (field)) + field = NULL_TREE; + } + return field; } }