summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-04 18:48:38 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-04 18:48:38 +0000
commitd15855b2d1739304f5b804208b1f4c8cee6c9834 (patch)
treee994e033726106d952196e298be9dbd809ea0100
parent137ce14a7ddf577f3518979177094142d4af0062 (diff)
downloadgcc-d15855b2d1739304f5b804208b1f4c8cee6c9834.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109342 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c26
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/parse/access9.C5
-rw-r--r--gcc/testsuite/g++.dg/tc1/dr52.C4
5 files changed, 34 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1dbf6004e9a..4487eba9c59 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 86763eb42bd..13aa29a0855 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 07b9a0df5f7..6ec417fb7df 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/parse/access9.C b/gcc/testsuite/g++.dg/parse/access9.C
new file mode 100644
index 00000000000..2c29016b047
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/access9.C
@@ -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" }
diff --git a/gcc/testsuite/g++.dg/tc1/dr52.C b/gcc/testsuite/g++.dg/tc1/dr52.C
index b0896d73fa7..4f4015dc958 100644
--- a/gcc/testsuite/g++.dg/tc1/dr52.C
+++ b/gcc/testsuite/g++.dg/tc1/dr52.C
@@ -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" }
}
};