diff options
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 2 | ||||
-rw-r--r-- | gcc/cp/parser.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/using-enum-1.C | 20 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/using-enum-2.C | 20 |
6 files changed, 56 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e330f73..8bd4a73 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,12 @@ 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 * parser.c (cp_parser_declarator): Add bool parameter. (cp_parser_direct_declarator): Likewise, use it. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 90f5108..75b46ac 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 22d7ba6..4dff139 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1250218..2a506f5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 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 * g++.dg/parse/friend9.C: New. * g++.dg/parse/friend10.C: Likewise. 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 index 0000000..9904d59 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/using-enum-1.C @@ -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 index 0000000..0738c80 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/using-enum-2.C @@ -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" } |