http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20420
--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-22
00:01:27 UTC ---
For Comment #4: the validate_nonmember_using_decl call at the beginning of
do_local_using_decl returns NULL_TREE for the second using declaration, but we
ignore that and return without error. That doesn't seem right for VAR_DECLs.
This combo patchlet passes testing:
Index: name-lookup.c
===================================================================
--- name-lookup.c (revision 190569)
+++ name-lookup.c (working copy)
@@ -441,7 +441,8 @@ supplement_binding_1 (cxx_binding *binding, tree d
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)))
@@ -2581,7 +2582,11 @@ do_local_using_decl (tree decl, tree scope, tree n
decl = validate_nonmember_using_decl (decl, scope, name);
if (decl == NULL_TREE)
- return;
+ {
+ if (TREE_CODE (orig_decl) == VAR_DECL)
+ error ("%qD is already declared in this scope", name);
+ return;
+ }
if (building_stmt_list_p ()
&& at_function_scope_p ())