mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-03 05:10:26 +08:00
re PR c++/24782 (wrongly accepted nested private typedef)
PR c++/24782 * parser.c (cp_parser_nested_name_specifier_opt): Preserve access checks, even when parsing tentatively. PR c++/24782 * g++.dg/parse/access9.C: New test. * g++.dg/tc1/dr52.C: Tweak error markers. From-SVN: r109342
This commit is contained in:
parent
2fb1388876
commit
19e65f304b
@ -1,3 +1,9 @@
|
||||
2006-01-04 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/24782
|
||||
* parser.c (cp_parser_nested_name_specifier_opt): Preserve access
|
||||
checks, even when parsing tentatively.
|
||||
|
||||
2006-01-04 Richard Henderson <rth@redhat.com>
|
||||
|
||||
Merge from gomp branch.
|
||||
|
@ -3517,7 +3517,6 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
|
||||
bool is_declaration)
|
||||
{
|
||||
bool success = false;
|
||||
tree access_check = NULL_TREE;
|
||||
cp_token_position start = 0;
|
||||
cp_token *token;
|
||||
|
||||
@ -3537,9 +3536,10 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
|
||||
|
||||
/* Remember where the nested-name-specifier starts. */
|
||||
if (cp_parser_uncommitted_to_tentative_parse_p (parser))
|
||||
start = cp_lexer_token_position (parser->lexer, false);
|
||||
|
||||
push_deferring_access_checks (dk_deferred);
|
||||
{
|
||||
start = cp_lexer_token_position (parser->lexer, false);
|
||||
push_deferring_access_checks (dk_deferred);
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
@ -3718,10 +3718,6 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
|
||||
parser->scope = new_scope;
|
||||
}
|
||||
|
||||
/* Retrieve any deferred checks. Do not pop this access checks yet
|
||||
so the memory will not be reclaimed during token replacing below. */
|
||||
access_check = get_deferred_access_checks ();
|
||||
|
||||
/* If parsing tentatively, replace the sequence of tokens that makes
|
||||
up the nested-name-specifier with a CPP_NESTED_NAME_SPECIFIER
|
||||
token. That way, should we re-parse the token stream, we will
|
||||
@ -3729,19 +3725,27 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
|
||||
we issue duplicate error messages. */
|
||||
if (success && start)
|
||||
{
|
||||
cp_token *token = cp_lexer_token_at (parser->lexer, start);
|
||||
cp_token *token;
|
||||
tree access_checks;
|
||||
|
||||
token = cp_lexer_token_at (parser->lexer, start);
|
||||
/* Reset the contents of the START token. */
|
||||
token->type = CPP_NESTED_NAME_SPECIFIER;
|
||||
token->value = build_tree_list (access_check, parser->scope);
|
||||
/* Retrieve any deferred checks. Do not pop this access checks yet
|
||||
so the memory will not be reclaimed during token replacing below. */
|
||||
access_checks = get_deferred_access_checks ();
|
||||
token->value = build_tree_list (copy_list (access_checks),
|
||||
parser->scope);
|
||||
TREE_TYPE (token->value) = parser->qualifying_scope;
|
||||
token->keyword = RID_MAX;
|
||||
|
||||
/* Purge all subsequent tokens. */
|
||||
cp_lexer_purge_tokens_after (parser->lexer, start);
|
||||
}
|
||||
|
||||
if (start)
|
||||
pop_to_parent_deferring_access_checks ();
|
||||
|
||||
pop_deferring_access_checks ();
|
||||
return success ? parser->scope : NULL_TREE;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
2006-01-04 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/24782
|
||||
* g++.dg/parse/access9.C: New test.
|
||||
* g++.dg/tc1/dr52.C: Tweak error markers.
|
||||
|
||||
2006-01-04 Richard Henderson <rth@redhat.com>
|
||||
|
||||
Merge from gomp branch.
|
||||
|
5
gcc/testsuite/g++.dg/parse/access9.C
Normal file
5
gcc/testsuite/g++.dg/parse/access9.C
Normal file
@ -0,0 +1,5 @@
|
||||
// PR c++/24782
|
||||
|
||||
class Foo { public: typedef int type1; };
|
||||
class Bar { private: typedef Foo type2; }; // { dg-error "private" }
|
||||
void g(Bar::type2::type1) {} // { dg-error "context" }
|
@ -17,7 +17,7 @@ struct B1 : B {};
|
||||
struct B2 : B {};
|
||||
|
||||
struct C
|
||||
{
|
||||
{ // { dg-error "C" }
|
||||
void foo(void);
|
||||
};
|
||||
|
||||
@ -29,6 +29,6 @@ public:
|
||||
void bar(void)
|
||||
{
|
||||
this->B::foo(); // { dg-error "" }
|
||||
this->C::foo(); // { dg-error "" }
|
||||
this->C::foo(); // { dg-error "inaccessible|context" }
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user