It's rarely useful to give an additional error message about error_mark_node
not being something else.

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

---
 gcc/cp/parser.c  | 8 +++++---
 gcc/cp/ChangeLog | 5 +++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 504f77a4908..f80bfc27e76 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -6420,9 +6420,11 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
                  == CPP_SCOPE))
            {
              token = cp_lexer_consume_token (parser->lexer);
-             error_at (token->location, "%<decltype%> evaluates to %qT, "
-                       "which is not a class or enumeration type",
-                       token->u.tree_check_value->value);
+             tree dtype = token->u.tree_check_value->value;
+             if (dtype != error_mark_node)
+               error_at (token->location, "%<decltype%> evaluates to %qT, "
+                         "which is not a class or enumeration type",
+                         dtype);
              parser->scope = error_mark_node;
              error_p = true;
              /* As below.  */
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f014423ca00..d07c0de82dd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-08-22  Jason Merrill  <ja...@redhat.com>
+
+       * parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant
+       error.
+
 2019-08-23  Iain Sandoe  <i...@sandoe.co.uk>
 
        PR pch/61250

base-commit: 9f271cbd097f75318691be869278c2bfa221d780
-- 
2.21.0

Reply via email to