diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2012-08-23 09:44:08 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2012-08-23 09:44:08 +0000 |
commit | 8597cab14b29f161d4847976f604058e0ac983ea (patch) | |
tree | 2862f6b164d5a15639114c27d3cb1153d64a8bf6 /gcc/cp | |
parent | fb489f55b58e5725bf04fbd26181c3c196fb5f32 (diff) | |
download | gcc-8597cab14b29f161d4847976f604058e0ac983ea.zip gcc-8597cab14b29f161d4847976f604058e0ac983ea.tar.gz gcc-8597cab14b29f161d4847976f604058e0ac983ea.tar.bz2 |
re PR c++/20420 (Incorrectly Accepts double declarations)
/cp
2012-08-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/20420
* name-lookup.c (supplement_binding_1): Handle specially enums
only in class templates.
(validate_nonmember_using_decl): Enforce 7.3.3/10 about duplicate
using declarations at function scope.
/testsuite
2012-08-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/20420
* g++.dg/lookup/using53.C: New.
From-SVN: r190618
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 13 |
2 files changed, 19 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0d9de13..58e6e1f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2012-08-23 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/20420 + * name-lookup.c (supplement_binding_1): Handle specially enums + only in class templates. + (validate_nonmember_using_decl): Enforce 7.3.3/10 about duplicate + using declarations at function scope. + 2012-08-21 Richard Guenther <rguenther@suse.de> * cp-tree.h (TREE_INDIRECT_USING): Use TREE_LANG_FLAG_0 accessor. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index f8dbfa1..22bc5e7 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -441,7 +441,8 @@ supplement_binding_1 (cxx_binding *binding, tree decl) template in order to handle late matching of underlying type on an opaque-enum-declaration followed by an enum-specifier. */ - || (TREE_CODE (TREE_TYPE (target_decl)) == ENUMERAL_TYPE + || (processing_template_decl + && TREE_CODE (TREE_TYPE (target_decl)) == ENUMERAL_TYPE && TREE_CODE (TREE_TYPE (target_bval)) == ENUMERAL_TYPE && (dependent_type_p (ENUM_UNDERLYING_TYPE (TREE_TYPE (target_decl))) @@ -2420,7 +2421,15 @@ validate_nonmember_using_decl (tree decl, tree scope, tree name) gcc_assert (DECL_P (decl)); /* Make a USING_DECL. */ - return push_using_decl (scope, name); + tree using_decl = push_using_decl (scope, name); + + if (using_decl == NULL_TREE + && at_function_scope_p () + && TREE_CODE (decl) == VAR_DECL) + /* C++11 7.3.3/10. */ + error ("%qD is already declared in this scope", name); + + return using_decl; } /* Process local and global using-declarations. */ |