diff mbox

[C++] PR 42021

Message ID 51B78309.8000100@oracle.com
State New
Headers show

Commit Message

Paolo Carlini June 11, 2013, 8:05 p.m. UTC
Hi,

this issue, which originally was about spelling out in the error message 
the ambiguous candidates, is by and large fixed. Only, we produce the 
whole diagnostic twice for the testcase at issue: first in 
cp_parser_lookup_name and then again in 
cp_parser_nested_name_specifier_opt. The below fixes that.

Tested x86_64-linux.

Thanks,
Paolo.

///////////////////////
2013-06-11  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/42021
	* parser.c (cp_parser_nested_name_specifier_opt): Avoid emitting
	again diagnostic already emitted by cp_parser_lookup_name.

Comments

Jason Merrill June 12, 2013, 1:38 p.m. UTC | #1
OK, but please add a comment.

Jason
Paolo Carlini June 12, 2013, 2:05 p.m. UTC | #2
On 06/12/2013 03:38 PM, Jason Merrill wrote:
> OK, but please add a comment.
Thanks. I added this:

               // cp_parser_lookup_name has the same diagnostic,
               // thus make sure to emit it almost once.

Paolo.
Paolo Carlini June 12, 2013, 2:35 p.m. UTC | #3
On 06/12/2013 04:05 PM, Paolo Carlini wrote:
> On 06/12/2013 03:38 PM, Jason Merrill wrote:
>> OK, but please add a comment.
> Thanks. I added this:
>
>               // cp_parser_lookup_name has the same diagnostic,
>               // thus make sure to emit it almost once.
As mentioned by Marc off-line, 'at most' is definitely better ;)

Paolo.
diff mbox

Patch

Index: parser.c
===================================================================
--- parser.c	(revision 199944)
+++ parser.c	(working copy)
@@ -5230,10 +5230,14 @@  cp_parser_nested_name_specifier_opt (cp_parser *pa
 				  decl);
 		      else if (ambiguous_decls)
 			{
-			  error_at (token->location,
-				    "reference to %qD is ambiguous",
-				    token->u.value);
-			  print_candidates (ambiguous_decls);
+			  if (cp_parser_uncommitted_to_tentative_parse_p
+			      (parser))
+			    {
+			      error_at (token->location,
+					"reference to %qD is ambiguous",
+					token->u.value);
+			      print_candidates (ambiguous_decls);
+			    }
 			  decl = error_mark_node;
 			}
 		      else