diff options
author | Fabien Chêne <fabien@gcc.gnu.org> | 2012-04-11 22:40:51 +0200 |
---|---|---|
committer | Fabien Chêne <fabien@gcc.gnu.org> | 2012-04-11 22:40:51 +0200 |
commit | af79925b5f99540716216ad419a7e312069079bd (patch) | |
tree | 43bf3c0280ad712e2711bc7271d35ca78f32ee7a /gcc/cp | |
parent | 6cc5558fe8380697c0274c905dc49637e1df0dcd (diff) | |
download | gcc-af79925b5f99540716216ad419a7e312069079bd.zip gcc-af79925b5f99540716216ad419a7e312069079bd.tar.gz gcc-af79925b5f99540716216ad419a7e312069079bd.tar.bz2 |
re PR c++/52465 (g++ rejects valid code with in-class using declaration)
gcc/testsuite/ChangeLog
2012-04-09 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/52465
* g++.dg/lookup/using52.C: New.
gcc/cp/ChangeLog
2012-04-09 Fabien Chêne <fabien@gcc.gnu.org>
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.
From-SVN: r186355
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 15 | ||||
-rw-r--r-- | gcc/cp/parser.c | 2 |
3 files changed, 23 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 525ce99..c822ca2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2012-04-11 Fabien Chêne <fabien@gcc.gnu.org> + + 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-11 Jason Merrill <jason@redhat.com> PR debug/45088 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 886a7b1..a81b0d1 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 <gdr@integrable-solutions.net> @@ -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 eac60f1..6809bc7 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -17845,6 +17845,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 |