public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-42] c++: using in diagnostics [PR102987]
Date: Fri, 29 Apr 2022 13:21:54 +0000 (GMT)	[thread overview]
Message-ID: <20220429132154.B69B6394B00F@sourceware.org> (raw)

https://gcc.gnu.org/g:a0a2554d7c86c126de85fcbd5bd7e16dbb5a2693

commit r13-42-ga0a2554d7c86c126de85fcbd5bd7e16dbb5a2693
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 14 17:35:35 2022 -0400

    c++: using in diagnostics [PR102987]
    
    The decl pretty-printing code wasn't looking at the flags parameter, so we
    were printing 'using' in the middle of an expression.
    
            PR c++/102987
    
    gcc/cp/ChangeLog:
    
            * error.cc (dump_decl) [USING_DECL]: Respect flags.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/diagnostic/using1.C: Check pretty-printing.

Diff:
---
 gcc/cp/error.cc                          | 18 +++++++++++-------
 gcc/testsuite/g++.dg/diagnostic/using1.C |  1 +
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index 2b07136b5ca..53a9073d99b 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -1439,16 +1439,20 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags)
 
     case USING_DECL:
       {
-	pp_cxx_ws_string (pp, "using");
-	tree scope = USING_DECL_SCOPE (t);
+	if (flags & TFF_DECL_SPECIFIERS)
+	  pp_cxx_ws_string (pp, "using");
 	bool variadic = false;
-	if (PACK_EXPANSION_P (scope))
+	if (!(flags & TFF_UNQUALIFIED_NAME))
 	  {
-	    scope = PACK_EXPANSION_PATTERN (scope);
-	    variadic = true;
+	    tree scope = USING_DECL_SCOPE (t);
+	    if (PACK_EXPANSION_P (scope))
+	      {
+		scope = PACK_EXPANSION_PATTERN (scope);
+		variadic = true;
+	      }
+	    dump_type (pp, scope, flags);
+	    pp_cxx_colon_colon (pp);
 	  }
-	dump_type (pp, scope, flags);
-	pp_cxx_colon_colon (pp);
 	dump_decl (pp, DECL_NAME (t), flags);
 	if (variadic)
 	  pp_cxx_ws_string (pp, "...");
diff --git a/gcc/testsuite/g++.dg/diagnostic/using1.C b/gcc/testsuite/g++.dg/diagnostic/using1.C
index eb4f18d1d8b..4090dd24a60 100644
--- a/gcc/testsuite/g++.dg/diagnostic/using1.C
+++ b/gcc/testsuite/g++.dg/diagnostic/using1.C
@@ -7,6 +7,7 @@ struct a {
 template <typename c> struct d : c {
   using c::e;
   using f = d;
+  // { dg-message "decltype .c::e" "" { target *-*-* } 0 }
   constexpr int g(decltype(e.b())) { return buh; } // { dg-error "buh" }
 };
 struct h {


                 reply	other threads:[~2022-04-29 13:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220429132154.B69B6394B00F@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).