]> 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:18:02 +0000 (10:18 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Tue, 19 Sep 2017 08:18:02 +0000 (08:18 +0000)
2017-09-19  Martin Liska  <mliska@suse.cz>

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

From-SVN: r252967

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

index 23d2985a862e1972b79ee61d61f621794e6d0e75..934784a39ca7771a4a0176a1824948952b167c33 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 b41cb819227204e8bbd024d9170065a4078115df..b62932ac2de431b52e6a0ef0e151d6409775b7aa 100644 (file)
@@ -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]== '-')