public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix target attribute handling (PR c++/81355).
@ 2017-07-28 11:13 Martin Liška
  2017-08-02 19:04 ` Jeff Law
  2017-09-18 13:01 ` Backport fix: [PATCH] " Martin Liška
  0 siblings, 2 replies; 11+ messages in thread
From: Martin Liška @ 2017-07-28 11:13 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 631 bytes --]

Hello.

Following patch skips empty strings in 'target' attribute.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

gcc/ChangeLog:

2017-07-13  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* attribs.c (sorted_attr_string): Skip empty strings.

gcc/testsuite/ChangeLog:

2017-07-13  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* g++.dg/other/pr81355.C: New test.
---
 gcc/attribs.c                        |  6 ++++++
 gcc/testsuite/g++.dg/other/pr81355.C | 14 ++++++++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/other/pr81355.C



[-- Attachment #2: 0001-Fix-target-attribute-handling-PR-c-81355.patch --]
[-- Type: text/x-patch, Size: 1290 bytes --]

diff --git a/gcc/attribs.c b/gcc/attribs.c
index 5eb19e82795..bf8452a3cec 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -725,6 +725,9 @@ sorted_attr_string (tree arglist)
     {
       const char *str = TREE_STRING_POINTER (TREE_VALUE (arg));
       size_t len = strlen (str);
+      /* Skip empty string.  */
+      if (len == 0)
+	continue;
       str_len_sum += len + 1;
       if (arg != arglist)
 	argnum++;
@@ -739,6 +742,9 @@ sorted_attr_string (tree arglist)
     {
       const char *str = TREE_STRING_POINTER (TREE_VALUE (arg));
       size_t len = strlen (str);
+      /* Skip empty string.  */
+      if (len == 0)
+	continue;
       memcpy (attr_str + str_len_sum, str, len);
       attr_str[str_len_sum + len] = TREE_CHAIN (arg) ? ',' : '\0';
       str_len_sum += len + 1;
diff --git a/gcc/testsuite/g++.dg/other/pr81355.C b/gcc/testsuite/g++.dg/other/pr81355.C
new file mode 100644
index 00000000000..d52b444261c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/pr81355.C
@@ -0,0 +1,14 @@
+/* { dg-do compile { target x86_64-*-* } } */
+
+__attribute__((target("default")))
+int foo() {return 1;}
+
+__attribute__((target("arch=core2", "")))
+int foo() {return 2;}
+
+__attribute__((target("sse4.2", "", "")))
+int foo() {return 2;}
+
+int main() {
+    return foo();
+}


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

* Re: [PATCH] Fix target attribute handling (PR c++/81355).
  2017-07-28 11:13 [PATCH] Fix target attribute handling (PR c++/81355) Martin Liška
@ 2017-08-02 19:04 ` Jeff Law
  2017-08-02 19:56   ` Martin Sebor
  2017-09-18 13:01 ` Backport fix: [PATCH] " Martin Liška
  1 sibling, 1 reply; 11+ messages in thread
From: Jeff Law @ 2017-08-02 19:04 UTC (permalink / raw)
  To: Martin Liška, gcc-patches

On 07/28/2017 05:13 AM, Martin Liška wrote:
> Hello.
> 
> Following patch skips empty strings in 'target' attribute.
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
> 
> Ready to be installed?
> Martin
> 
> gcc/ChangeLog:
> 
> 2017-07-13  Martin Liska  <mliska@suse.cz>
> 
> 	PR c++/81355
> 	* attribs.c (sorted_attr_string): Skip empty strings.
> 
> gcc/testsuite/ChangeLog:
> 
> 2017-07-13  Martin Liska  <mliska@suse.cz>
> 
> 	PR c++/81355
> 	* g++.dg/other/pr81355.C: New test.
OK.  THough one could legitimately ask if this ought to be a parsing error.

jeff

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

* Re: [PATCH] Fix target attribute handling (PR c++/81355).
  2017-08-02 19:04 ` Jeff Law
@ 2017-08-02 19:56   ` Martin Sebor
  2017-08-08  4:59     ` [PATCH][v2] " Martin Liška
  0 siblings, 1 reply; 11+ messages in thread
From: Martin Sebor @ 2017-08-02 19:56 UTC (permalink / raw)
  To: Jeff Law, Martin Liška, gcc-patches

On 08/02/2017 01:04 PM, Jeff Law wrote:
> On 07/28/2017 05:13 AM, Martin Liška wrote:
>> Hello.
>>
>> Following patch skips empty strings in 'target' attribute.
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>
>> Ready to be installed?
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>
>> 	PR c++/81355
>> 	* attribs.c (sorted_attr_string): Skip empty strings.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>
>> 	PR c++/81355
>> 	* g++.dg/other/pr81355.C: New test.
> OK.  THough one could legitimately ask if this ought to be a parsing error.

I would suggest to at least issue a warning.  It seems that
the empty string must almost certainly be a bug here, say due
to unintended macro expansion.

Otherwise, if it should remain silently (and intentionally)
accepted, I recommend to document it.  As it is, the manual
says that the "string" argument is equivalent to compiling
with -mstring which for "" would be rejected by the driver.

Martin

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

* [PATCH][v2] Fix target attribute handling (PR c++/81355).
  2017-08-02 19:56   ` Martin Sebor
@ 2017-08-08  4:59     ` Martin Liška
  2017-08-08 16:36       ` Jason Merrill
  2017-08-08 18:03       ` Martin Sebor
  0 siblings, 2 replies; 11+ messages in thread
From: Martin Liška @ 2017-08-08  4:59 UTC (permalink / raw)
  To: Martin Sebor, Jeff Law, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]

On 08/02/2017 09:56 PM, Martin Sebor wrote:
> On 08/02/2017 01:04 PM, Jeff Law wrote:
>> On 07/28/2017 05:13 AM, Martin Liška wrote:
>>> Hello.
>>>
>>> Following patch skips empty strings in 'target' attribute.
>>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>>
>>> Ready to be installed?
>>> Martin
>>>
>>> gcc/ChangeLog:
>>>
>>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>>
>>>     PR c++/81355
>>>     * attribs.c (sorted_attr_string): Skip empty strings.
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>>
>>>     PR c++/81355
>>>     * g++.dg/other/pr81355.C: New test.
>> OK.  THough one could legitimately ask if this ought to be a parsing error.
> 
> I would suggest to at least issue a warning.  It seems that
> the empty string must almost certainly be a bug here, say due
> to unintended macro expansion.
> 
> Otherwise, if it should remain silently (and intentionally)
> accepted, I recommend to document it.  As it is, the manual
> says that the "string" argument is equivalent to compiling
> with -mstring which for "" would be rejected by the driver.
> 
> Martin

Thanks you both for feedback. I decided to come up with an error message for that.

Feedback appreciated.

Thanks,
Martin

[-- Attachment #2: 0001-Fix-target-attribute-handling-PR-c-81355.patch --]
[-- Type: text/x-patch, Size: 2001 bytes --]

From 7fd264acf60829b8ed4921c6659f01a87c944d44 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 12 Jul 2017 15:51:45 +0200
Subject: [PATCH] Fix target attribute handling (PR c++/81355).

gcc/ChangeLog:

2017-07-13  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* config/i386/i386.c (ix86_valid_target_attribute_inner_p):
	Report error for an empty string argument of target attribute.

gcc/testsuite/ChangeLog:

2017-07-13  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* g++.dg/other/pr81355.C: New test.
---
 gcc/config/i386/i386.c               |  6 ++++++
 gcc/testsuite/g++.dg/other/pr81355.C | 14 ++++++++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/other/pr81355.C

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 42e0ddaca56..62f08f9a80d 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7140,6 +7140,12 @@ ix86_valid_target_attribute_inner_p (tree args, char *p_strings[],
   /* Handle multiple arguments separated by commas.  */
   next_optstr = ASTRDUP (TREE_STRING_POINTER (args));
 
+  if (next_optstr && *next_optstr == '\0')
+  {
+      error ("attribute %<target%> argument can't be an empty string");
+      return false;
+  }
+
   while (next_optstr && *next_optstr != '\0')
     {
       char *p = next_optstr;
diff --git a/gcc/testsuite/g++.dg/other/pr81355.C b/gcc/testsuite/g++.dg/other/pr81355.C
new file mode 100644
index 00000000000..42b25b72611
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/pr81355.C
@@ -0,0 +1,14 @@
+/* { dg-do compile { target x86_64-*-* } } */
+
+__attribute__((target("default")))
+int foo() {return 1;}
+
+__attribute__((target("arch=core2", "")))
+int foo2() {return 2;} /* { dg-error "attribute .target. argument can't be an empty string" } */
+
+__attribute__((target("sse4.2", "", "")))
+int foo3() {return 2;} /* { dg-error "attribute .target. argument can't be an empty string" } */
+
+int main() {
+    return foo() + foo2() + foo3();
+}
-- 
2.13.3


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

* Re: [PATCH][v2] Fix target attribute handling (PR c++/81355).
  2017-08-08  4:59     ` [PATCH][v2] " Martin Liška
@ 2017-08-08 16:36       ` Jason Merrill
  2017-08-08 18:03       ` Martin Sebor
  1 sibling, 0 replies; 11+ messages in thread
From: Jason Merrill @ 2017-08-08 16:36 UTC (permalink / raw)
  To: Martin Liška; +Cc: Martin Sebor, Jeff Law, gcc-patches List

On Tue, Aug 8, 2017 at 12:59 AM, Martin Liška <mliska@suse.cz> wrote:
> On 08/02/2017 09:56 PM, Martin Sebor wrote:
>> On 08/02/2017 01:04 PM, Jeff Law wrote:
>>> On 07/28/2017 05:13 AM, Martin Liška wrote:
>>>> Hello.
>>>>
>>>> Following patch skips empty strings in 'target' attribute.
>>>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>>>
>>>> Ready to be installed?
>>>> Martin
>>>>
>>>> gcc/ChangeLog:
>>>>
>>>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>>>
>>>>     PR c++/81355
>>>>     * attribs.c (sorted_attr_string): Skip empty strings.
>>>>
>>>> gcc/testsuite/ChangeLog:
>>>>
>>>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>>>
>>>>     PR c++/81355
>>>>     * g++.dg/other/pr81355.C: New test.
>>> OK.  THough one could legitimately ask if this ought to be a parsing error.
>>
>> I would suggest to at least issue a warning.  It seems that
>> the empty string must almost certainly be a bug here, say due
>> to unintended macro expansion.
>>
>> Otherwise, if it should remain silently (and intentionally)
>> accepted, I recommend to document it.  As it is, the manual
>> says that the "string" argument is equivalent to compiling
>> with -mstring which for "" would be rejected by the driver.
>>
>> Martin
>
> Thanks you both for feedback. I decided to come up with an error message for that.
>
> Feedback appreciated.

I'd think to check it in handle_target_argument rather than require
all targets to check it.

Jason

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

* Re: [PATCH][v2] Fix target attribute handling (PR c++/81355).
  2017-08-08  4:59     ` [PATCH][v2] " Martin Liška
  2017-08-08 16:36       ` Jason Merrill
@ 2017-08-08 18:03       ` Martin Sebor
  2017-08-09 10:45         ` Martin Liška
  1 sibling, 1 reply; 11+ messages in thread
From: Martin Sebor @ 2017-08-08 18:03 UTC (permalink / raw)
  To: Martin Liška, Jeff Law, gcc-patches

On 08/07/2017 10:59 PM, Martin Liška wrote:
> On 08/02/2017 09:56 PM, Martin Sebor wrote:
>> On 08/02/2017 01:04 PM, Jeff Law wrote:
>>> On 07/28/2017 05:13 AM, Martin Liška wrote:
>>>> Hello.
>>>>
>>>> Following patch skips empty strings in 'target' attribute.
>>>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>>>
>>>> Ready to be installed?
>>>> Martin
>>>>
>>>> gcc/ChangeLog:
>>>>
>>>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>>>
>>>>     PR c++/81355
>>>>     * attribs.c (sorted_attr_string): Skip empty strings.
>>>>
>>>> gcc/testsuite/ChangeLog:
>>>>
>>>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>>>
>>>>     PR c++/81355
>>>>     * g++.dg/other/pr81355.C: New test.
>>> OK.  THough one could legitimately ask if this ought to be a parsing error.
>>
>> I would suggest to at least issue a warning.  It seems that
>> the empty string must almost certainly be a bug here, say due
>> to unintended macro expansion.
>>
>> Otherwise, if it should remain silently (and intentionally)
>> accepted, I recommend to document it.  As it is, the manual
>> says that the "string" argument is equivalent to compiling
>> with -mstring which for "" would be rejected by the driver.
>>
>> Martin
>
> Thanks you both for feedback. I decided to come up with an error message for that.
>
> Feedback appreciated.

My only comment is on the text of the error message.  I think
the %' directive is supposed to be used instead of a bare
apostrophe.  But rather than using the somewhat informal "can't"
I would suggest to follow other similar diagnostics that might
print something like:

   empty string in attribute %<target%>

(analogous to "empty precision in %s format" or "empty scalar
initializer" etc. in gcc.pot)

or

   attribute %<target%> argument may not be empty

(similar to "output filename may not be empty").

Martin

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

* Re: [PATCH][v2] Fix target attribute handling (PR c++/81355).
  2017-08-08 18:03       ` Martin Sebor
@ 2017-08-09 10:45         ` Martin Liška
  2017-08-09 19:44           ` Jason Merrill
  0 siblings, 1 reply; 11+ messages in thread
From: Martin Liška @ 2017-08-09 10:45 UTC (permalink / raw)
  To: Martin Sebor, Jeff Law, gcc-patches, Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 2152 bytes --]

On 08/08/2017 08:03 PM, Martin Sebor wrote:
> On 08/07/2017 10:59 PM, Martin Liška wrote:
>> On 08/02/2017 09:56 PM, Martin Sebor wrote:
>>> On 08/02/2017 01:04 PM, Jeff Law wrote:
>>>> On 07/28/2017 05:13 AM, Martin Liška wrote:
>>>>> Hello.
>>>>>
>>>>> Following patch skips empty strings in 'target' attribute.
>>>>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>>>>
>>>>> Ready to be installed?
>>>>> Martin
>>>>>
>>>>> gcc/ChangeLog:
>>>>>
>>>>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>>>>
>>>>>     PR c++/81355
>>>>>     * attribs.c (sorted_attr_string): Skip empty strings.
>>>>>
>>>>> gcc/testsuite/ChangeLog:
>>>>>
>>>>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>>>>
>>>>>     PR c++/81355
>>>>>     * g++.dg/other/pr81355.C: New test.
>>>> OK.  THough one could legitimately ask if this ought to be a parsing error.
>>>
>>> I would suggest to at least issue a warning.  It seems that
>>> the empty string must almost certainly be a bug here, say due
>>> to unintended macro expansion.
>>>
>>> Otherwise, if it should remain silently (and intentionally)
>>> accepted, I recommend to document it.  As it is, the manual
>>> says that the "string" argument is equivalent to compiling
>>> with -mstring which for "" would be rejected by the driver.
>>>
>>> Martin
>>
>> Thanks you both for feedback. I decided to come up with an error message for that.
>>
>> Feedback appreciated.
> 
> My only comment is on the text of the error message.  I think
> the %' directive is supposed to be used instead of a bare
> apostrophe.  But rather than using the somewhat informal "can't"
> I would suggest to follow other similar diagnostics that might
> print something like:
> 
>   empty string in attribute %<target%>
> 
> (analogous to "empty precision in %s format" or "empty scalar
> initializer" etc. in gcc.pot)
> 
> or
> 
>   attribute %<target%> argument may not be empty
> 
> (similar to "output filename may not be empty").
> 
> Martin

Hi.

Thank you both for review, both notes resolved in v3.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

[-- Attachment #2: 0001-Fix-target-attribute-handling-PR-c-81355.patch --]
[-- Type: text/x-patch, Size: 2116 bytes --]

From 227a41219ebb9a10bda80767f5b5f3e460a3e9b9 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 12 Jul 2017 15:51:45 +0200
Subject: [PATCH] Fix target attribute handling (PR c++/81355).

gcc/ChangeLog:

2017-07-13  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* c-attribs.c (handle_target_attribute):
	Report warning for an empty string argument of target attribute.

gcc/testsuite/ChangeLog:

2017-07-13  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* g++.dg/other/pr81355.C: New test.
---
 gcc/c-family/c-attribs.c             | 13 +++++++++++++
 gcc/testsuite/g++.dg/other/pr81355.C | 14 ++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/other/pr81355.C

diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 626ffa1cde7..b4252229beb 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -3116,6 +3116,19 @@ handle_target_attribute (tree *node, tree name, tree args, int flags,
 						      flags))
     *no_add_attrs = true;
 
+  /* Check that there's no empty string in values of the attribute.  */
+  for (tree t = args; t != NULL_TREE; t = TREE_CHAIN (t))
+    {
+      tree value = TREE_VALUE (t);
+      if (TREE_CODE (value) == STRING_CST
+	  && TREE_STRING_LENGTH (value) == 1
+	  && TREE_STRING_POINTER (value)[0] == '\0')
+	{
+	  warning (OPT_Wattributes, "empty string in attribute %<target%>");
+	  *no_add_attrs = true;
+	}
+    }
+
   return NULL_TREE;
 }
 
diff --git a/gcc/testsuite/g++.dg/other/pr81355.C b/gcc/testsuite/g++.dg/other/pr81355.C
new file mode 100644
index 00000000000..89d1b419581
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/pr81355.C
@@ -0,0 +1,14 @@
+/* { dg-do compile { target x86_64-*-* } } */
+
+__attribute__((target("default")))
+int foo() {return 1;}
+
+__attribute__((target("arch=core2", "")))
+int foo2() {return 2;} /* { dg-warning "empty string in attribute .target." } */
+
+__attribute__((target("sse4.2", "", "")))
+int foo3() {return 2;} /* { dg-warning "empty string in attribute .target." } */
+
+int main() {
+    return foo() + foo2() + foo3();
+}
-- 
2.13.3


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

* Re: [PATCH][v2] Fix target attribute handling (PR c++/81355).
  2017-08-09 10:45         ` Martin Liška
@ 2017-08-09 19:44           ` Jason Merrill
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Merrill @ 2017-08-09 19:44 UTC (permalink / raw)
  To: Martin Liška; +Cc: Martin Sebor, Jeff Law, gcc-patches List

On Wed, Aug 9, 2017 at 6:45 AM, Martin Liška <mliska@suse.cz> wrote:
> On 08/08/2017 08:03 PM, Martin Sebor wrote:
>> On 08/07/2017 10:59 PM, Martin Liška wrote:
>>> On 08/02/2017 09:56 PM, Martin Sebor wrote:
>>>> On 08/02/2017 01:04 PM, Jeff Law wrote:
>>>>> On 07/28/2017 05:13 AM, Martin Liška wrote:
>>>>>> Hello.
>>>>>>
>>>>>> Following patch skips empty strings in 'target' attribute.
>>>>>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>>>>>
>>>>>> Ready to be installed?
>>>>>> Martin
>>>>>>
>>>>>> gcc/ChangeLog:
>>>>>>
>>>>>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>>>>>
>>>>>>     PR c++/81355
>>>>>>     * attribs.c (sorted_attr_string): Skip empty strings.
>>>>>>
>>>>>> gcc/testsuite/ChangeLog:
>>>>>>
>>>>>> 2017-07-13  Martin Liska  <mliska@suse.cz>
>>>>>>
>>>>>>     PR c++/81355
>>>>>>     * g++.dg/other/pr81355.C: New test.
>>>>> OK.  THough one could legitimately ask if this ought to be a parsing error.
>>>>
>>>> I would suggest to at least issue a warning.  It seems that
>>>> the empty string must almost certainly be a bug here, say due
>>>> to unintended macro expansion.
>>>>
>>>> Otherwise, if it should remain silently (and intentionally)
>>>> accepted, I recommend to document it.  As it is, the manual
>>>> says that the "string" argument is equivalent to compiling
>>>> with -mstring which for "" would be rejected by the driver.
>>>>
>>>> Martin
>>>
>>> Thanks you both for feedback. I decided to come up with an error message for that.
>>>
>>> Feedback appreciated.
>>
>> My only comment is on the text of the error message.  I think
>> the %' directive is supposed to be used instead of a bare
>> apostrophe.  But rather than using the somewhat informal "can't"
>> I would suggest to follow other similar diagnostics that might
>> print something like:
>>
>>   empty string in attribute %<target%>
>>
>> (analogous to "empty precision in %s format" or "empty scalar
>> initializer" etc. in gcc.pot)
>>
>> or
>>
>>   attribute %<target%> argument may not be empty
>>
>> (similar to "output filename may not be empty").
>>
>> Martin
>
> Hi.
>
> Thank you both for review, both notes resolved in v3.
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?

OK.

Jason

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

* Backport fix: [PATCH] Fix target attribute handling (PR c++/81355).
  2017-07-28 11:13 [PATCH] Fix target attribute handling (PR c++/81355) Martin Liška
  2017-08-02 19:04 ` Jeff Law
@ 2017-09-18 13:01 ` Martin Liška
  2017-09-18 13:06   ` Jakub Jelinek
  1 sibling, 1 reply; 11+ messages in thread
From: Martin Liška @ 2017-09-18 13:01 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

Hello.

As discussed here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81224

We have fallout caused by the patch and it's backport to active branches.
I'm planning to revert the patch and install patch that will ignore empty string
values. I'm testing the patch.

Jakub do we really want it also for GCC 7? Note that the problematic test-case is OK on GCC 7 branch
as it contains your patch mentioned in discussion.

Martin





[-- Attachment #2: 0002-Ignore-empty-string-in-target-attribute-PR-c-81355.patch --]
[-- Type: text/x-patch, Size: 1604 bytes --]

From d0f04048f86d2e13079900e8fee7fdf08643197a Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Mon, 18 Sep 2017 14:46:31 +0200
Subject: [PATCH 2/2] Ignore empty string in target attribute (PR c++/81355).

gcc/ChangeLog:

2017-09-18  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* config/i386/i386.c (sorted_attr_string): Skip empty strings.
---
 gcc/config/i386/i386.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index b41cb819227..b62932ac2de 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -36766,6 +36766,9 @@ sorted_attr_string (tree arglist)
     {
       const char *str = TREE_STRING_POINTER (TREE_VALUE (arg));
       size_t len = strlen (str);
+      /* Skip empty string.  */
+      if (len == 0)
+	continue;
       str_len_sum += len + 1;
       if (arg != arglist)
 	argnum++;
@@ -36780,11 +36783,21 @@ sorted_attr_string (tree arglist)
     {
       const char *str = TREE_STRING_POINTER (TREE_VALUE (arg));
       size_t len = strlen (str);
+      /* Skip empty string.  */
+      if (len == 0)
+	continue;
       memcpy (attr_str + str_len_sum, str, len);
       attr_str[str_len_sum + len] = TREE_CHAIN (arg) ? ',' : '\0';
       str_len_sum += len + 1;
     }
 
+  /* Strip ',' character at the end.  */
+  if (str_len_sum > 0 && attr_str[str_len_sum - 1] == ',')
+    {
+      attr_str[str_len_sum - 1] = '\0';
+      str_len_sum--;
+    }
+
   /* Replace "=,-" with "_".  */
   for (i = 0; i < strlen (attr_str); i++)
     if (attr_str[i] == '=' || attr_str[i]== '-')
-- 
2.14.1


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

* Re: Backport fix: [PATCH] Fix target attribute handling (PR c++/81355).
  2017-09-18 13:01 ` Backport fix: [PATCH] " Martin Liška
@ 2017-09-18 13:06   ` Jakub Jelinek
  2017-09-19  8:19     ` Martin Liška
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Jelinek @ 2017-09-18 13:06 UTC (permalink / raw)
  To: Martin Liška; +Cc: gcc-patches

On Mon, Sep 18, 2017 at 03:01:53PM +0200, Martin Liška wrote:
> As discussed here:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81224
> 
> We have fallout caused by the patch and it's backport to active branches.
> I'm planning to revert the patch and install patch that will ignore empty string
> values. I'm testing the patch.
> 
> Jakub do we really want it also for GCC 7? Note that the problematic test-case is OK on GCC 7 branch
> as it contains your patch mentioned in discussion.

The question is, has the GCC 7 patch changed solely testcases where we'd
ICE on into ones where we warn, or are there cases where we used to accept
it and now warn?
Generally we don't want to introduce new warnings/errors on release branches
on something that used to be accepted, unless really necessary.

	Jakub

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

* Re: Backport fix: [PATCH] Fix target attribute handling (PR c++/81355).
  2017-09-18 13:06   ` Jakub Jelinek
@ 2017-09-19  8:19     ` Martin Liška
  0 siblings, 0 replies; 11+ messages in thread
From: Martin Liška @ 2017-09-19  8:19 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On 09/18/2017 03:05 PM, Jakub Jelinek wrote:
> On Mon, Sep 18, 2017 at 03:01:53PM +0200, Martin Liška wrote:
>> As discussed here:
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81224
>>
>> We have fallout caused by the patch and it's backport to active branches.
>> I'm planning to revert the patch and install patch that will ignore empty string
>> values. I'm testing the patch.
>>
>> Jakub do we really want it also for GCC 7? Note that the problematic test-case is OK on GCC 7 branch
>> as it contains your patch mentioned in discussion.
> 
> The question is, has the GCC 7 patch changed solely testcases where we'd
> ICE on into ones where we warn, or are there cases where we used to accept
> it and now warn?
> Generally we don't want to introduce new warnings/errors on release branches
> on something that used to be accepted, unless really necessary.
> 
> 	Jakub
> 

I've just installed the patch to GCC 5.x and 6.x. I'll do the same for 7.x in order
to preserve the behavior.

Martin

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

end of thread, other threads:[~2017-09-19  8:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-28 11:13 [PATCH] Fix target attribute handling (PR c++/81355) Martin Liška
2017-08-02 19:04 ` Jeff Law
2017-08-02 19:56   ` Martin Sebor
2017-08-08  4:59     ` [PATCH][v2] " Martin Liška
2017-08-08 16:36       ` Jason Merrill
2017-08-08 18:03       ` Martin Sebor
2017-08-09 10:45         ` Martin Liška
2017-08-09 19:44           ` Jason Merrill
2017-09-18 13:01 ` Backport fix: [PATCH] " Martin Liška
2017-09-18 13:06   ` Jakub Jelinek
2017-09-19  8:19     ` Martin Liška

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