diff mbox series

[C++] Fix g++.dg/template/pr84789.C on new concepts branch.

Message ID 20190716084835.32606-1-jason@redhat.com
State New
Headers show
Series [C++] Fix g++.dg/template/pr84789.C on new concepts branch. | expand

Commit Message

Jason Merrill July 16, 2019, 8:48 a.m. UTC
On the concepts branch I ran into trouble where a pre-parsed dependent
nested-name-specifier got replaced on a subsequent parse with is_declaration
by one with typenames resolved, which was then used wrongly on a further
parse with !is_declaration.

Tested x86_64-pc-linux-gnu, applying to trunk.

    * parser.c (cp_parser_nested_name_specifier_opt): If the token is
    already CPP_NESTED_NAME_SPECIFIER, leave it alone.
---
 gcc/cp/parser.c  | 3 ++-
 gcc/cp/ChangeLog | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)


base-commit: 48db11b0846d94dbb8d620cfca36eb00f5644d1c
diff mbox series

Patch

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index f91c50ead67..14a2168eb6d 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -6275,7 +6275,8 @@  cp_parser_nested_name_specifier_opt (cp_parser *parser,
   cp_token *token;
 
   /* Remember where the nested-name-specifier starts.  */
-  if (cp_parser_uncommitted_to_tentative_parse_p (parser))
+  if (cp_parser_uncommitted_to_tentative_parse_p (parser)
+      && cp_lexer_next_token_is_not (parser->lexer, CPP_NESTED_NAME_SPECIFIER))
     {
       start = cp_lexer_token_position (parser->lexer, false);
       push_deferring_access_checks (dk_deferred);
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a18959d6388..bd85c705629 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@ 
+2019-07-16  Jason Merrill  <jason@redhat.com>
+
+	* parser.c (cp_parser_nested_name_specifier_opt): If the token is
+	already CPP_NESTED_NAME_SPECIFIER, leave it alone.
+
 2019-07-12  Jakub Jelinek  <jakub@redhat.com>
 
 	* parser.c (cp_parser_omp_clause_name): Handle order clause.