public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-4489] target: support spaces in target attribute.
Date: Tue, 19 Oct 2021 06:51:53 +0000 (GMT)	[thread overview]
Message-ID: <20211019065153.8DDDB385842B@sourceware.org> (raw)

https://gcc.gnu.org/g:df592811f950301ed3b10a08e476dad0f2eff26a

commit r12-4489-gdf592811f950301ed3b10a08e476dad0f2eff26a
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Oct 4 14:06:14 2021 +0200

    target: support spaces in target attribute.
    
            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.

Diff:
---
 gcc/config/i386/i386-options.c           |  2 ++
 gcc/system.h                             | 21 +++++++++++++++++++++
 gcc/testsuite/gcc.target/i386/pr102374.c |  3 +++
 3 files changed, 26 insertions(+)

diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
index e7a3bd4aaea..c9523b26f49 100644
--- a/gcc/config/i386/i386-options.c
+++ b/gcc/config/i386/i386-options.c
@@ -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] == '-')
 	{
diff --git a/gcc/system.h b/gcc/system.h
index adde3e264b6..17a6a553b0b 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -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
index 00000000000..21aa76011ed
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr102374.c
@@ -0,0 +1,3 @@
+/* PR target/102374 */
+
+void calculate_sse(void) __attribute__ ((__target__ ("	no-avx, sse2   ")));


                 reply	other threads:[~2021-10-19  6:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211019065153.8DDDB385842B@sourceware.org \
    --to=marxin@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).