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

* [C++ Patch PING] (was: [C++ Patch] PR 62315 ("do not print typename in diagnostic if the original code does not have it"))
  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 ` 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
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Carlini @ 2017-06-23  9:53 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

Hi,

gently pingning this:

On 02/06/2017 10:35, Paolo Carlini wrote:
> 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.

     https://gcc.gnu.org/ml/gcc-patches/2017-06/msg00099.html

Thanks!
Paolo.

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

* Re: [C++ Patch] PR 62315 ("do not print typename in diagnostic if the original code does not have it")
  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 ` Jason Merrill
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2017-06-23 20:40 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: gcc-patches

OK.

On Fri, Jun 2, 2017 at 4:35 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> 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.
>
> //////////////////
>
>

^ 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).