Hi,
this issue is probably easy to resolve, one way or another, but I find
it rather curious: as the submitted testcase explains, we reject the
trivial:
enum E { V };
using E::V;
because "'E' is not a namespace", but I don't see anything in C++11
explicitly outlawing enums. In fact, current clang accept the whole
using-enum-1.C attached below. Then there is the case of *scoped enums*,
which are mentioned in negative in C++11 (7.3.3/7), and current clang
accepts, the whole using-enum-2.C attached below. Anyay, patchlet passes
testing on x86_64-linux.
Thanks,
Paolo.
/////////////////////
Index: cp/name-lookup.c
===================================================================
--- cp/name-lookup.c (revision 211466)
+++ cp/name-lookup.c (working copy)
@@ -2487,7 +2487,7 @@ validate_nonmember_using_decl (tree decl, tree sco
member-declaration. */
if (TYPE_P (scope))
{
- error ("%qT is not a namespace", scope);
+ error ("%qT is not a namespace or unscoped enum", scope);
return NULL_TREE;
}
else if (scope == error_mark_node)
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 211467)
+++ cp/parser.c (working copy)
@@ -16022,6 +16022,8 @@ cp_parser_using_declaration (cp_parser* parser,
/*is_declaration=*/true);
if (!qscope)
qscope = global_namespace;
+ else if (UNSCOPED_ENUM_P (qscope))
+ qscope = CP_TYPE_CONTEXT (qscope);
if (access_declaration_p && cp_parser_error_occurred (parser))
/* Something has already gone wrong; there's no need to parse
Index: testsuite/g++.dg/cpp0x/using-enum-1.C
===================================================================
--- testsuite/g++.dg/cpp0x/using-enum-1.C (revision 0)
+++ testsuite/g++.dg/cpp0x/using-enum-1.C (working copy)
@@ -0,0 +1,20 @@
+// PR c++/60265
+// { dg-do compile { target c++11 } }
+
+namespace A
+{
+ enum E { V };
+
+ using E::V;
+}
+
+void foo()
+{
+ using A::E::V;
+}
+
+using A::E::V;
+
+enum F { U };
+
+using F::U;
Index: testsuite/g++.dg/cpp0x/using-enum-2.C
===================================================================
--- testsuite/g++.dg/cpp0x/using-enum-2.C (revision 0)
+++ testsuite/g++.dg/cpp0x/using-enum-2.C (working copy)
@@ -0,0 +1,20 @@
+// PR c++/60265
+// { dg-do compile { target c++11 } }
+
+namespace A
+{
+ enum class E { V };
+
+ using E::V; // { dg-error "not a namespace or unscoped enum" }
+}
+
+void foo()
+{
+ using A::E::V; // { dg-error "not a namespace or unscoped enum" }
+}
+
+using A::E::V; // { dg-error "not a namespace or unscoped enum" }
+
+enum class F { U };
+
+using F::U; // { dg-error "not a namespace or unscoped enum" }