[C++,1/2] * parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant error.

Message ID 20190823231833.30678-1-jason@redhat.com
State New
Headers show
Series
  • [C++,1/2] * parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant error.
Related show

Commit Message

Jason Merrill Aug. 23, 2019, 11:18 p.m.
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(-)


base-commit: 9f271cbd097f75318691be869278c2bfa221d780
-- 
2.21.0

Patch

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  <jason@redhat.com>
+
+	* parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant
+	error.
+
 2019-08-23  Iain Sandoe  <iain@sandoe.co.uk>
 
 	PR pch/61250