From: Martin Liska Date: Tue, 19 Sep 2017 08:12:58 +0000 (+0200) Subject: Ignore empty string in target attribute (PR c++/81355). X-Git-Tag: releases/gcc-5.5.0~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2211c974acea7293979423be782ee7528464d5b;p=thirdparty%2Fgcc.git Ignore empty string in target attribute (PR c++/81355). 2017-09-19 Martin Liska PR c++/81355 * config/i386/i386.c (sorted_attr_string): Skip empty strings. From-SVN: r252965 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c8e7f33eb4e6..9a8afeb3c267 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-09-19 Martin Liska + + PR c++/81355 + * config/i386/i386.c (sorted_attr_string): Skip empty strings. + 2017-09-19 Martin Liska Revert backport: diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 189317458d6c..886e612f0e4a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -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]== '-')