This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Backport fix: [PATCH] Fix target attribute handling (PR c++/81355).


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




>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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]