From: Matthias Kretz <m.kretz@gsi.de>
To: <gcc-patches@gcc.gnu.org>, David Malcolm <dmalcolm@redhat.com>
Cc: <libstdc++@gcc.gnu.org>
Subject: Re: [PATCH] Add gnu::diagnose_as attribute
Date: Tue, 4 May 2021 21:22:36 +0200 [thread overview]
Message-ID: <4097047.Kzl1nTV4Ca@excalibur> (raw)
In-Reply-To: <bf4768b29ea2e91bbeccdf6cb17cafbbfcacdcce.camel@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2034 bytes --]
> On Tuesday, 4 May 2021 15:34:13 CEST David Malcolm wrote:
> > Does the patch interact correctly with the %H and %I codes that try to
> > show the differences between two template types?
While looking into this, I noticed that given
namespace std {
struct A {};
typedef A B;
}
const std::B would print as "'const B' {aka 'const std::A'}", i.e. without
printing the scope of the typedef. I traced it to cp/error.c (dump_type). In
the `if (TYPE_P (t) && typedef_variant_p (t))` branch, in the final else
branch only cv-qualifiers and identifier are printed:
pp_cxx_cv_qualifier_seq (pp, t);
pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
I believe the following should go in between, correct?
pp_cxx_cv_qualifier_seq (pp, t);
if (! (flags & TFF_UNQUALIFIED_NAME))
dump_scope (pp, CP_DECL_CONTEXT (TYPE_NAME (t)), flags);
pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
This is important for my diagnose_as patch because otherwise the output is:
'const string' {aka 'const std::string'}
which is confusing and unnecessarily verbose. Patch below.
From: Matthias Kretz <kretz@kde.org>
dump_type on 'const std::string' should not print 'const string' unless
TFF_UNQUALIFIED_NAME is requested.
gcc/cp/ChangeLog:
* error.c: Call dump_scope when printing a typedef.
---
gcc/cp/error.c | 2 ++
1 file changed, 2 insertions(+)
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
std::experimental::simd https://github.com/VcDevel/std-simd
──────────────────────────────────────────────────────────────────────────
[-- Attachment #2: 0001-Add-missing-scope-in-typedef-diagnostic.patch --]
[-- Type: text/x-patch, Size: 427 bytes --]
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 10b547afaa7..edeaad44bcd 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -511,6 +511,8 @@ dump_type (cxx_pretty_printer *pp, tree t, int flags)
else
{
pp_cxx_cv_qualifier_seq (pp, t);
+ if (! (flags & TFF_UNQUALIFIED_NAME))
+ dump_scope (pp, CP_DECL_CONTEXT (TYPE_NAME (t)), flags);
pp_cxx_tree_identifier (pp, TYPE_IDENTIFIER (t));
return;
}
next prev parent reply other threads:[~2021-05-04 19:22 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <14205410.xuKvIAzr1H@excalibur>
[not found] ` <20210427094648.GL3008@redhat.com>
2021-05-04 11:13 ` Matthias Kretz
2021-05-04 13:34 ` David Malcolm
2021-05-04 14:23 ` Matthias Kretz
2021-05-04 14:32 ` Matthias Kretz
2021-05-04 19:00 ` David Malcolm
2021-05-04 19:22 ` Matthias Kretz [this message]
2021-05-14 16:05 ` Martin Sebor
2021-05-26 21:33 ` Matthias Kretz
2021-05-27 17:39 ` Jason Merrill
2021-05-27 18:54 ` Matthias Kretz
2021-05-27 21:15 ` Jason Merrill
2021-05-27 22:07 ` Matthias Kretz
2021-05-28 3:05 ` Jason Merrill
2021-05-28 7:42 ` Matthias Kretz
2021-06-01 19:12 ` Jason Merrill
2021-06-01 21:01 ` Matthias Kretz
2021-06-11 10:01 ` Matthias Kretz
2021-06-15 15:51 ` Jason Merrill
2021-06-15 20:56 ` Matthias Kretz
2021-06-16 0:48 ` Jason Merrill
2021-06-22 7:30 ` Matthias Kretz
2021-06-22 19:52 ` Jason Merrill
2021-06-22 20:01 ` Matthias Kretz
2021-06-22 20:12 ` Jason Merrill
2021-07-01 9:28 ` Matthias Kretz
2021-07-01 15:18 ` Jason Merrill
2021-07-05 14:18 ` Matthias Kretz
2021-07-07 22:34 ` Jason Merrill
2021-07-07 8:23 ` Matthias Kretz
2021-07-08 1:19 ` Jason Merrill
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=4097047.Kzl1nTV4Ca@excalibur \
--to=m.kretz@gsi.de \
--cc=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@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).