This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to do_class_using_decl for c++/26102
- From: Jason Merrill <jason at redhat dot com>
- To: "gcc-patches >> GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 05 Sep 2006 21:14:27 -0400
- Subject: C++ PATCH to do_class_using_decl for c++/26102
There were two bugs in 26102:
1) We were identifying "using B2::i" as dependent even though B2 is not
a dependent base.
2) We failed to recognize the USING_DECL as dependent in later uses.
This patch fixes both. Tested x86_64-pc-linux-gnu, applied to trunk.
2006-09-05 Jason Merrill <jason@redhat.com>
PR c++/26102
* name-lookup.c (do_class_using_decl): Try to find the base even
if bases_dependent_p.
* pt.c (type_dependent_expression_p): A USING_DECL is dependent.
Index: cp/pt.c
===================================================================
*** cp/pt.c (revision 116703)
--- cp/pt.c (working copy)
*************** type_dependent_expression_p (tree expres
*** 12862,12868 ****
return false;
/* An unresolved name is always dependent. */
! if (TREE_CODE (expression) == IDENTIFIER_NODE)
return true;
/* Some expression forms are never type-dependent. */
--- 12866,12873 ----
return false;
/* An unresolved name is always dependent. */
! if (TREE_CODE (expression) == IDENTIFIER_NODE
! || TREE_CODE (expression) == USING_DECL)
return true;
/* Some expression forms are never type-dependent. */
Index: cp/name-lookup.c
===================================================================
*** cp/name-lookup.c (revision 116703)
--- cp/name-lookup.c (working copy)
*************** do_class_using_decl (tree scope, tree na
*** 2824,2841 ****
class type. However, if all of the base classes are
non-dependent, then we can avoid delaying the check until
instantiation. */
! if (!scope_dependent_p && !bases_dependent_p)
{
base_kind b_kind;
- tree binfo;
binfo = lookup_base (current_class_type, scope, ba_any, &b_kind);
if (b_kind < bk_proper_base)
{
! error_not_base_type (scope, current_class_type);
! return NULL_TREE;
}
!
! if (!name_dependent_p)
{
decl = lookup_member (binfo, name, 0, false);
if (!decl)
--- 2824,2842 ----
class type. However, if all of the base classes are
non-dependent, then we can avoid delaying the check until
instantiation. */
! if (!scope_dependent_p)
{
base_kind b_kind;
binfo = lookup_base (current_class_type, scope, ba_any, &b_kind);
if (b_kind < bk_proper_base)
{
! if (!bases_dependent_p)
! {
! error_not_base_type (scope, current_class_type);
! return NULL_TREE;
! }
}
! else if (!name_dependent_p)
{
decl = lookup_member (binfo, name, 0, false);
if (!decl)
Index: testsuite/g++.dg/template/using14.C
===================================================================
*** testsuite/g++.dg/template/using14.C (revision 0)
--- testsuite/g++.dg/template/using14.C (revision 0)
***************
*** 0 ****
--- 1,21 ----
+ // PR c++/26102
+
+ template <class T> struct B1 { int i(); };
+
+ struct B2 { int i(); };
+
+ template <class T> struct C : public B1<T>, public B2
+ {
+ using B2::i;
+ void f()
+ {
+ i(); // should be accepted
+ i.i(); // { dg-error "" }
+ }
+ };
+
+ int main()
+ {
+ C<int> c;
+ c.f(); // { dg-error "instantiated" }
+ }