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

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