aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2006-10-03 18:04:10 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2006-10-03 18:04:10 +0000
commit981114e175b2702448171adf1448f9daacb56921 (patch)
tree5af52248c32ff0f2af23a82d7887c3bb88baede1
parent9f9900dbb6fe19fad02a53df9efecae35bd65976 (diff)
downloadgcc-981114e175b2702448171adf1448f9daacb56921.zip
gcc-981114e175b2702448171adf1448f9daacb56921.tar.gz
gcc-981114e175b2702448171adf1448f9daacb56921.tar.bz2
re PR c++/29138 (access declarations don't work for classes)
PR c++/29138 * decl2.c (grokfield): Don't handle access declarations here. * parser.c (cp_parser_using_declaration): Handle access declarations too. (cp_parser_block_declaration): Adjust calls to cp_parser_using_declaration. (cp_parser_member_declaration): Likewise. Use cp_parser_using_declaration to look for access_declarations. PR c++/29138 * g++.dg/inherit/access8.C: New test. * g++.dg/template/dtor4.C: Tweak error messages. From-SVN: r117409
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/decl2.c10
-rw-r--r--gcc/cp/parser.c66
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/inherit/access8.C25
-rw-r--r--gcc/testsuite/g++.dg/template/dtor4.C2
6 files changed, 89 insertions, 31 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f82e4f5..835aabb 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,14 @@
+2006-10-03 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/29138
+ * decl2.c (grokfield): Don't handle access declarations here.
+ * parser.c (cp_parser_using_declaration): Handle access
+ declarations too.
+ (cp_parser_block_declaration): Adjust calls to
+ cp_parser_using_declaration.
+ (cp_parser_member_declaration): Likewise. Use
+ cp_parser_using_declaration to look for access_declarations.
+
2006-10-03 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/29291
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index a6187e2..42e9240 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -769,16 +769,6 @@ grokfield (const cp_declarator *declarator,
const char *asmspec = 0;
int flags = LOOKUP_ONLYCONVERTING;
- if (!declspecs->any_specifiers_p
- && declarator->kind == cdk_id
- && declarator->u.id.qualifying_scope
- && TYPE_P (declarator->u.id.qualifying_scope)
- && IS_AGGR_TYPE (declarator->u.id.qualifying_scope)
- && TREE_CODE (declarator->u.id.unqualified_name) == IDENTIFIER_NODE)
- /* Access declaration */
- return do_class_using_decl (declarator->u.id.qualifying_scope,
- declarator->u.id.unqualified_name);
-
if (init
&& TREE_CODE (init) == TREE_LIST
&& TREE_VALUE (init) == error_mark_node
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7b66ea3..cb2346a 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1518,8 +1518,8 @@ static tree cp_parser_qualified_namespace_specifier
(cp_parser *);
static void cp_parser_namespace_alias_definition
(cp_parser *);
-static void cp_parser_using_declaration
- (cp_parser *);
+static bool cp_parser_using_declaration
+ (cp_parser *, bool);
static void cp_parser_using_directive
(cp_parser *);
static void cp_parser_asm_definition
@@ -7184,7 +7184,8 @@ cp_parser_block_declaration (cp_parser *parser,
cp_parser_using_directive (parser);
/* Otherwise, it's a using-declaration. */
else
- cp_parser_using_declaration (parser);
+ cp_parser_using_declaration (parser,
+ /*access_declaration_p=*/false);
}
/* If the next keyword is `__label__' we have a label declaration. */
else if (token1->keyword == RID_LABEL)
@@ -10582,14 +10583,21 @@ cp_parser_qualified_namespace_specifier (cp_parser* parser)
return cp_parser_namespace_name (parser);
}
-/* Parse a using-declaration.
+/* Parse a using-declaration, or, if ACCESS_DECLARATION_P is true, an
+ access declaration.
using-declaration:
using typename [opt] :: [opt] nested-name-specifier unqualified-id ;
- using :: unqualified-id ; */
+ using :: unqualified-id ;
-static void
-cp_parser_using_declaration (cp_parser* parser)
+ access-declaration:
+ qualified-id ;
+
+ */
+
+static bool
+cp_parser_using_declaration (cp_parser* parser,
+ bool access_declaration_p)
{
cp_token *token;
bool typename_p = false;
@@ -10598,18 +10606,23 @@ cp_parser_using_declaration (cp_parser* parser)
tree identifier;
tree qscope;
- /* Look for the `using' keyword. */
- cp_parser_require_keyword (parser, RID_USING, "`using'");
-
- /* Peek at the next token. */
- token = cp_lexer_peek_token (parser->lexer);
- /* See if it's `typename'. */
- if (token->keyword == RID_TYPENAME)
+ if (access_declaration_p)
+ cp_parser_parse_tentatively (parser);
+ else
{
- /* Remember that we've seen it. */
- typename_p = true;
- /* Consume the `typename' token. */
- cp_lexer_consume_token (parser->lexer);
+ /* Look for the `using' keyword. */
+ cp_parser_require_keyword (parser, RID_USING, "`using'");
+
+ /* Peek at the next token. */
+ token = cp_lexer_peek_token (parser->lexer);
+ /* See if it's `typename'. */
+ if (token->keyword == RID_TYPENAME)
+ {
+ /* Remember that we've seen it. */
+ typename_p = true;
+ /* Consume the `typename' token. */
+ cp_lexer_consume_token (parser->lexer);
+ }
}
/* Look for the optional global scope qualification. */
@@ -10643,6 +10656,14 @@ cp_parser_using_declaration (cp_parser* parser)
/*declarator_p=*/true,
/*optional_p=*/false);
+ if (access_declaration_p)
+ {
+ if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
+ cp_parser_simulate_error (parser);
+ if (!cp_parser_parse_definitely (parser))
+ return false;
+ }
+
/* The function we call to handle a using-declaration is different
depending on what scope we are in. */
if (qscope == error_mark_node || identifier == error_mark_node)
@@ -10676,6 +10697,8 @@ cp_parser_using_declaration (cp_parser* parser)
/* Look for the final `;'. */
cp_parser_require (parser, CPP_SEMICOLON, "`;'");
+
+ return true;
}
/* Parse a using-directive.
@@ -13551,8 +13574,8 @@ cp_parser_member_declaration (cp_parser* parser)
if (cp_lexer_next_token_is_keyword (parser->lexer, RID_USING))
{
/* Parse the using-declaration. */
- cp_parser_using_declaration (parser);
-
+ cp_parser_using_declaration (parser,
+ /*access_declaration_p=*/false);
return;
}
@@ -13572,6 +13595,9 @@ cp_parser_member_declaration (cp_parser* parser)
return;
}
+ if (cp_parser_using_declaration (parser, /*access_declaration=*/true))
+ return;
+
/* Parse the decl-specifier-seq. */
cp_parser_decl_specifier_seq (parser,
CP_PARSER_FLAGS_OPTIONAL,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fb05a15..1e45696 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2006-10-03 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/29138
+ * g++.dg/inherit/access8.C: New test.
+ * g++.dg/template/dtor4.C: Tweak error messages.
+
2006-10-03 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR fortran/27478
diff --git a/gcc/testsuite/g++.dg/inherit/access8.C b/gcc/testsuite/g++.dg/inherit/access8.C
new file mode 100644
index 0000000..a11ea8e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/inherit/access8.C
@@ -0,0 +1,25 @@
+// PR c++/29138
+
+class A
+{
+public:
+ int i;
+ class A1
+ {
+ int j;
+ };
+};
+
+class B : private A
+{
+public:
+ A::i;
+ A::A1;
+};
+
+void
+f ()
+{
+ B b;
+ B::A1 a1;
+}
diff --git a/gcc/testsuite/g++.dg/template/dtor4.C b/gcc/testsuite/g++.dg/template/dtor4.C
index 6d7cd23..4f277b2 100644
--- a/gcc/testsuite/g++.dg/template/dtor4.C
+++ b/gcc/testsuite/g++.dg/template/dtor4.C
@@ -5,5 +5,5 @@
template<int> struct A
{
- ~A<0>(); // { dg-error "declaration" }
+ ~A<0>(); // { dg-error "parse error|declaration" }
};