From: fabien Date: Sun, 15 Apr 2012 20:22:44 +0000 (+0000) Subject: 2012-04-15 Fabien Chêne X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=208ee050c84d5f6674eae1883f53f6396e47d753;ds=sidebyside 2012-04-15 Fabien Chêne PR c++/52465 * g++.dg/lookup/using52.C: New. gcc/cp/ChangeLog 2012-04-15 Fabien Chêne PR c++/52465 * parser.c (cp_parser_class_name): Call strip_using_decl and return the target decl. * name-lookup.c (strip_using_decl): Returns NULL_TREE if the decl to be stripped is NULL_TREE. (qualify_lookup): Call strip_using_decl and perform some checks on the target decl. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@186473 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a3a58f677fc..e75d32a472b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2012-04-15 Fabien Chêne + + PR c++/52465 + * parser.c (cp_parser_class_name): Call strip_using_decl and + return the target decl. + * name-lookup.c (strip_using_decl): Returns NULL_TREE if the decl + to be stripped is NULL_TREE. + (qualify_lookup): Call strip_using_decl and perform some checks on + the target decl. + 2012-04-13 Jason Merrill PR c++/52824 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 235134249ac..fedf626e7a0 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1,5 +1,5 @@ /* Definitions for C++ name lookup routines. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Contributed by Gabriel Dos Reis @@ -400,6 +400,9 @@ pop_binding (tree id, tree decl) tree strip_using_decl (tree decl) { + if (decl == NULL_TREE) + return NULL_TREE; + while (TREE_CODE (decl) == USING_DECL && !DECL_DEPENDENT_P (decl)) decl = USING_DECL_DECLS (decl); return decl; @@ -4115,9 +4118,13 @@ qualify_lookup (tree val, int flags) return false; if ((flags & LOOKUP_PREFER_NAMESPACES) && TREE_CODE (val) == NAMESPACE_DECL) return true; - if ((flags & LOOKUP_PREFER_TYPES) - && (TREE_CODE (val) == TYPE_DECL || TREE_CODE (val) == TEMPLATE_DECL)) - return true; + if (flags & LOOKUP_PREFER_TYPES) + { + tree target_val = strip_using_decl (val); + if (TREE_CODE (target_val) == TYPE_DECL + || TREE_CODE (target_val) == TEMPLATE_DECL) + return true; + } if (flags & (LOOKUP_PREFER_NAMESPACES | LOOKUP_PREFER_TYPES)) return false; /* Look through lambda things that we shouldn't be able to see. */ diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c4b4dd44855..5bff67db7f4 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -17841,6 +17841,8 @@ cp_parser_class_name (cp_parser *parser, decl = TYPE_NAME (decl); } + decl = strip_using_decl (decl); + /* Check to see that it is really the name of a class. */ if (TREE_CODE (decl) == TEMPLATE_ID_EXPR && TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 853c7461c17..82324c6d16c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-04-15 Fabien Chêne + + PR c++/52465 + * g++.dg/lookup/using52.C: New. + 2012-04-13 Jason Merrill PR c++/52824 diff --git a/gcc/testsuite/g++.dg/lookup/using52.C b/gcc/testsuite/g++.dg/lookup/using52.C new file mode 100644 index 00000000000..bf2620714e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using52.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// PR c++/52645 + +class A +{ +protected: + struct B {}; +}; + +class C : A +{ +protected: + using A::B; + + struct D : public B {}; +};