]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/60265 ([C++11] using-declaration of enumerator fails if fully qualified)
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 11 Jun 2014 17:28:14 +0000 (17:28 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 11 Jun 2014 17:28:14 +0000 (17:28 +0000)
/cp
2014-06-11  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/60265
* parser.c (cp_parser_using_declaration): Handle unscoped enums.
* name-lookup.c (validate_nonmember_using_decl): Adjust error
message.

/testsuite
2014-06-11  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/60265
* g++.dg/cpp0x/using-enum-1.C: New.
* g++.dg/cpp0x/using-enum-2.C: Likewise.

From-SVN: r211479

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/using-enum-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/using-enum-2.C [new file with mode: 0644]

index e330f73ad048ce0ac8d5e747b43913d90d75f992..8bd4a7389d233cc6ff3c0d3bd2aa333ffe543cee 100644 (file)
@@ -1,3 +1,10 @@
+2014-06-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/60265
+       * parser.c (cp_parser_using_declaration): Handle unscoped enums.
+       * name-lookup.c (validate_nonmember_using_decl): Adjust error
+       message.
+
 2014-06-11  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/19200
index 90f51083915bdcd0cd347df91b4592d437d58ccb..75b46ac9c7dc5c2e47eb44db0acc51aa02eb2d96 100644 (file)
@@ -2487,7 +2487,7 @@ validate_nonmember_using_decl (tree decl, tree scope, tree name)
        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 22d7ba69fe6d7755c5e48a27bce3e2ba8f1583f5..4dff139ff5da3a6b9effd63d3e844cfff8ab5d88 100644 (file)
@@ -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 12502181eb047e972c43f079ee5657f1dbc41008..2a506f596c9dd00441af41884c9bac86713e75b1 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/60265
+       * g++.dg/cpp0x/using-enum-1.C: New.
+       * g++.dg/cpp0x/using-enum-2.C: Likewise.
+
 2014-06-11  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/19200
diff --git a/gcc/testsuite/g++.dg/cpp0x/using-enum-1.C b/gcc/testsuite/g++.dg/cpp0x/using-enum-1.C
new file mode 100644 (file)
index 0000000..9904d59
--- /dev/null
@@ -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;
diff --git a/gcc/testsuite/g++.dg/cpp0x/using-enum-2.C b/gcc/testsuite/g++.dg/cpp0x/using-enum-2.C
new file mode 100644 (file)
index 0000000..0738c80
--- /dev/null
@@ -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" }