Commit c7bb3484 by Paolo Carlini Committed by Paolo Carlini

re PR c++/60265 ([C++11] using-declaration of enumerator fails if fully qualified)

/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
parent 37251385
2014-06-11 Paolo Carlini <paolo.carlini@oracle.com> 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 PR c++/19200
* parser.c (cp_parser_declarator): Add bool parameter. * parser.c (cp_parser_declarator): Add bool parameter.
(cp_parser_direct_declarator): Likewise, use it. (cp_parser_direct_declarator): Likewise, use it.
......
...@@ -2487,7 +2487,7 @@ validate_nonmember_using_decl (tree decl, tree scope, tree name) ...@@ -2487,7 +2487,7 @@ validate_nonmember_using_decl (tree decl, tree scope, tree name)
member-declaration. */ member-declaration. */
if (TYPE_P (scope)) if (TYPE_P (scope))
{ {
error ("%qT is not a namespace", scope); error ("%qT is not a namespace or unscoped enum", scope);
return NULL_TREE; return NULL_TREE;
} }
else if (scope == error_mark_node) else if (scope == error_mark_node)
......
...@@ -16022,6 +16022,8 @@ cp_parser_using_declaration (cp_parser* parser, ...@@ -16022,6 +16022,8 @@ cp_parser_using_declaration (cp_parser* parser,
/*is_declaration=*/true); /*is_declaration=*/true);
if (!qscope) if (!qscope)
qscope = global_namespace; qscope = global_namespace;
else if (UNSCOPED_ENUM_P (qscope))
qscope = CP_TYPE_CONTEXT (qscope);
if (access_declaration_p && cp_parser_error_occurred (parser)) if (access_declaration_p && cp_parser_error_occurred (parser))
/* Something has already gone wrong; there's no need to parse /* Something has already gone wrong; there's no need to parse
......
2014-06-11 Paolo Carlini <paolo.carlini@oracle.com> 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 PR c++/19200
* g++.dg/parse/friend9.C: New. * g++.dg/parse/friend9.C: New.
* g++.dg/parse/friend10.C: Likewise. * g++.dg/parse/friend10.C: Likewise.
......
// 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;
// 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" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment