public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 62315 ("do not print typename in diagnostic if the original code does not have it")
@ 2017-06-02  8:35 Paolo Carlini
  2017-06-23  9:53 ` [C++ Patch PING] (was: [C++ Patch] PR 62315 ("do not print typename in diagnostic if the original code does not have it")) Paolo Carlini
  2017-06-23 20:40 ` [C++ Patch] PR 62315 ("do not print typename in diagnostic if the original code does not have it") Jason Merrill
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Carlini @ 2017-06-02  8:35 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 279 bytes --]

Hi,

a while ago Manuel noticed that printing 'typename' in error messages 
about missing 'typename' can be confusing. That seems easy to fix, in 
fact we already handle correctly a similar situation in grokdeclarator. 
Tested x86_64-linux.

Thanks, Paolo.

//////////////////



[-- Attachment #2: CL_62315 --]
[-- Type: text/plain, Size: 329 bytes --]

/cp
2017-06-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/62315
	* parser.c (cp_parser_diagnose_invalid_type_name): Don't print
	'typename' in error messages about missing 'typename'.

/testsuite
2017-06-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/62315
	* g++.dg/parse/typedef2.C: Specify a dg-error string.

[-- Attachment #3: patch_62315 --]
[-- Type: text/plain, Size: 1579 bytes --]

Index: testsuite/g++.dg/parse/typedef2.C
===================================================================
--- testsuite/g++.dg/parse/typedef2.C	(revision 248783)
+++ testsuite/g++.dg/parse/typedef2.C	(working copy)
@@ -1,3 +1,2 @@
 template <typename T> struct B { typedef typename T::X X; };
-template <typename T> struct A { typedef B<T>::X::Y Z; }; // { dg-error "" }
- 
+template <typename T> struct A { typedef B<T>::X::Y Z; }; // { dg-error "before 'B<T>::X::Y' because 'B<T>::X'" }
Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 248783)
+++ cp/parser.c	(working copy)
@@ -3270,9 +3270,21 @@ cp_parser_diagnose_invalid_type_name (cp_parser *p
 	}
       else if (TYPE_P (parser->scope)
 	       && dependent_scope_p (parser->scope))
-	error_at (location, "need %<typename%> before %<%T::%E%> because "
-		  "%qT is a dependent scope",
-		  parser->scope, id, parser->scope);
+	{
+	  if (TREE_CODE (parser->scope) == TYPENAME_TYPE)
+	    error_at (location,
+		      "need %<typename%> before %<%T::%D::%E%> because "
+		      "%<%T::%D%> is a dependent scope",
+		      TYPE_CONTEXT (parser->scope),
+		      TYPENAME_TYPE_FULLNAME (parser->scope),
+		      id,
+		      TYPE_CONTEXT (parser->scope),
+		      TYPENAME_TYPE_FULLNAME (parser->scope));
+	  else
+	    error_at (location, "need %<typename%> before %<%T::%E%> because "
+		      "%qT is a dependent scope",
+		      parser->scope, id, parser->scope);
+	}
       else if (TYPE_P (parser->scope))
 	{
 	  if (!COMPLETE_TYPE_P (parser->scope))

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-23 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02  8:35 [C++ Patch] PR 62315 ("do not print typename in diagnostic if the original code does not have it") Paolo Carlini
2017-06-23  9:53 ` [C++ Patch PING] (was: [C++ Patch] PR 62315 ("do not print typename in diagnostic if the original code does not have it")) Paolo Carlini
2017-06-23 20:40 ` [C++ Patch] PR 62315 ("do not print typename in diagnostic if the original code does not have it") Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).