diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c1d347d02bd..88199d6bed3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-11-18 Fabien ChĂȘne + + PR c++/51141 + * search.c (lookup_field_1): Handle USING_DECLs for the storted + case. + 2011-11-18 Paolo Carlini PR c++/51150 diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 9f308e29d79..3894c685884 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -436,6 +436,14 @@ lookup_field_1 (tree type, tree name, bool want_type) 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; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ca5740fcd90..ce066cd2413 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2011-11-18 Fabien ChĂȘne + + PR c++/51141 + * 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. + 2011-11-18 Ulrich Weigand * gcc.c-torture/compile/pr44707.c: Do not assume assembler diff --git a/gcc/testsuite/g++.dg/debug/using6.C b/gcc/testsuite/g++.dg/debug/using6.C new file mode 100644 index 00000000000..8f73d37ffa0 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/using6.C @@ -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; +}; diff --git a/gcc/testsuite/g++.dg/lookup/using46.C b/gcc/testsuite/g++.dg/lookup/using46.C new file mode 100644 index 00000000000..6f0f5bca090 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using46.C @@ -0,0 +1,62 @@ +// PR c++/51141 +// { dg-do compile } +// { dg-options "-fpermissive -w -Werror" } + +typedef int size_t; +template < size_t, size_t > struct AlignedBuffer {}; + +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; +}; diff --git a/gcc/testsuite/g++.dg/lookup/using47.C b/gcc/testsuite/g++.dg/lookup/using47.C new file mode 100644 index 00000000000..c81864705c4 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using47.C @@ -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(); + } +}; diff --git a/gcc/testsuite/g++.dg/lookup/using48.C b/gcc/testsuite/g++.dg/lookup/using48.C new file mode 100644 index 00000000000..e6dc3fab77c --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using48.C @@ -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; diff --git a/gcc/testsuite/g++.dg/lookup/using49.C b/gcc/testsuite/g++.dg/lookup/using49.C new file mode 100644 index 00000000000..391476ac472 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using49.C @@ -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))); + } +};