]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
target: support spaces in target attribute.
authorMartin Liska <mliska@suse.cz>
Mon, 4 Oct 2021 12:06:14 +0000 (14:06 +0200)
committerMartin Liska <mliska@suse.cz>
Tue, 19 Oct 2021 06:51:32 +0000 (08:51 +0200)
PR target/102374

gcc/ChangeLog:

* config/i386/i386-options.c (ix86_valid_target_attribute_inner_p): Strip whitespaces.
* system.h (strip_whilespaces): New function.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr102374.c: New test.

gcc/config/i386/i386-options.c
gcc/system.h
gcc/testsuite/gcc.target/i386/pr102374.c [new file with mode: 0644]

index e7a3bd4aaeadca5f4ecccf3aba0f22321c8b67f9..c9523b26f499aee97df92c03fe5df7e637884635 100644 (file)
@@ -1146,6 +1146,8 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
          next_optstr = NULL;
        }
 
+      p = strip_whitespaces (p, &len);
+
       /* Recognize no-xxx.  */
       if (len > 3 && p[0] == 'n' && p[1] == 'o' && p[2] == '-')
        {
index adde3e264b6c3a0a7728eb6028910015885715bc..17a6a553b0b5b8772e01335975ec3a54f3ccbd63 100644 (file)
@@ -1305,4 +1305,25 @@ startswith (const char *str, const char *prefix)
   return strncmp (str, prefix, strlen (prefix)) == 0;
 }
 
+/* Strip white spaces from STRING with LEN length.
+   A stripped string is returned and LEN is updated accordingly.  */
+
+static inline char *
+strip_whitespaces (char *string, size_t *len)
+{
+  while (string[0] == ' ' || string[0] == '\t')
+    {
+      --(*len);
+      ++string;
+    }
+
+  while (string[*len - 1] == ' ' || string[*len - 1] == '\t')
+    {
+      string[*len - 1] = '\0';
+      --(*len);
+    }
+
+  return string;
+}
+
 #endif /* ! GCC_SYSTEM_H */
diff --git a/gcc/testsuite/gcc.target/i386/pr102374.c b/gcc/testsuite/gcc.target/i386/pr102374.c
new file mode 100644 (file)
index 0000000..21aa760
--- /dev/null
@@ -0,0 +1,3 @@
+/* PR target/102374 */
+
+void calculate_sse(void) __attribute__ ((__target__ (" no-avx, sse2   ")));