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