]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Ignore empty string in target attribute (PR c++/81355).
authorMartin Liska <mliska@suse.cz>
Tue, 19 Sep 2017 08:12:58 +0000 (10:12 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Tue, 19 Sep 2017 08:12:58 +0000 (08:12 +0000)
2017-09-19  Martin Liska  <mliska@suse.cz>

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

From-SVN: r252965

gcc/ChangeLog
gcc/config/i386/i386.c

index c8e7f33eb4e67d444607a324ec726e0852c8d979..9a8afeb3c2674ddb2d068b20f17f8f77ade035e9 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-19  Martin Liska  <mliska@suse.cz>
+
+       PR c++/81355
+       * config/i386/i386.c (sorted_attr_string): Skip empty strings.
+
 2017-09-19  Martin Liska  <mliska@suse.cz>
 
        Revert backport:
index 189317458d6c753896e565575dded75e2be9539a..886e612f0e4a2ccfc8dd77a796b78df6c009e14f 100644 (file)
@@ -35037,6 +35037,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++;
@@ -35051,11 +35054,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]== '-')