From: Jason Merrill <jason@redhat.com>
To: Marek Polacek <polacek@redhat.com>,
Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Cc: Marek Polacek via Gcc-patches <gcc-patches@gcc.gnu.org>,
Jakub Jelinek <jakub@redhat.com>
Subject: Re: [PATCH v5] attribs: Implement -Wno-attributes=vendor::attr [PR101940]
Date: Sat, 6 Nov 2021 15:29:57 -0400 [thread overview]
Message-ID: <516f3ddd-8634-9d73-ddd4-ae470f4284cf@redhat.com> (raw)
In-Reply-To: <YYbJUy7p7coNn88n@redhat.com>
On 11/6/21 14:28, Marek Polacek wrote:
> On Sat, Nov 06, 2021 at 02:32:26AM +0100, Bernhard Reutner-Fischer wrote:
>> On 6 November 2021 01:21:43 CET, Marek Polacek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>>
>>>
>>> Thanks, so like this? I'm including an incremental diff so that it's
>>> clear what changed:
>>>
>>> diff --git a/gcc/attribs.c b/gcc/attribs.c
>>> index d5fba7f4bbb..addfe6f6c80 100644
>>> --- a/gcc/attribs.c
>>> +++ b/gcc/attribs.c
>>> @@ -237,7 +237,7 @@ check_attribute_tables (void)
>>> the end of parsing of all TUs. */
>>> static vec<attribute_spec *> ignored_attributes_table;
>>>
>>> -/* Parse arguments ARGS of -Wno-attributes=.
>>> +/* Parse arguments V of -Wno-attributes=.
>>> Currently we accept:
>>> vendor::attr
>>> vendor::
>>> @@ -252,12 +252,15 @@ handle_ignored_attributes_option (vec<char *> *v)
>>>
>>> for (auto opt : v)
>>> {
>>> + /* We're going to be modifying the string. */
>>> + opt = xstrdup (opt);
>>> char *q = strstr (opt, "::");
>>> /* We don't accept '::attr'. */
>>> if (q == nullptr || q == opt)
>>> {
>>> error ("wrong argument to ignored attributes");
>>> inform (input_location, "valid format is %<ns::attr%> or %<ns::%>");
>>> + free (opt);
>>> continue;
>>> }
>>
>> Only xstrdup here, after the strstr check?
>> Should maybe strdup the rest here, not full opt..
>
> No, I want q to point into the copy of the string, since I'm about
> to modify it. And I'd prefer a single call to xstrdup rather than
> two.
It occurs to me that instead of calling xstrdup at all, since you're
already passing the strings to get_identifier you could use
get_identifier_with_length instead, and then refer to IDENTIFIER_POINTER
of the result.
Jason
next prev parent reply other threads:[~2021-11-06 19:30 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 17:06 [PATCH] " Marek Polacek
2021-09-20 17:38 ` Jakub Jelinek
2021-09-20 18:37 ` Marek Polacek
2021-09-20 19:03 ` [PATCH v2] " Marek Polacek
2021-09-20 19:08 ` [PATCH] " Jakub Jelinek
2021-09-20 22:59 ` [PATCH v3] " Marek Polacek
2021-09-23 18:25 ` Jason Merrill
2021-09-28 20:20 ` [PATCH v4] " Marek Polacek
2021-10-11 15:17 ` Marek Polacek
2021-10-29 16:47 ` Marek Polacek
2021-11-05 18:48 ` Jason Merrill
2021-11-06 0:21 ` [PATCH v5] " Marek Polacek
2021-11-06 1:32 ` Bernhard Reutner-Fischer
2021-11-06 18:28 ` Marek Polacek
2021-11-06 19:29 ` Jason Merrill [this message]
2021-11-06 20:29 ` Bernhard Reutner-Fischer
2021-11-09 1:41 ` [PATCH v6] " Marek Polacek
2021-11-09 5:12 ` Jason Merrill
2021-11-09 7:09 ` Bernhard Reutner-Fischer
2021-11-09 15:55 ` Marek Polacek
2021-11-09 17:27 ` Jason Merrill
2021-11-09 19:17 ` [PATCH v7] " Marek Polacek
2021-11-09 19:47 ` Bernhard Reutner-Fischer
2021-11-09 19:57 ` Bernhard Reutner-Fischer
2021-11-09 20:23 ` Marek Polacek
2021-11-09 21:30 ` [PATCH v8] " Marek Polacek
2021-11-10 5:53 ` Jason Merrill
2021-11-09 15:51 ` [PATCH v6] " Marek Polacek
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=516f3ddd-8634-9d73-ddd4-ae470f4284cf@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=polacek@redhat.com \
--cc=rep.dot.nop@gmail.com \
/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).