public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Sebastian Huber <sh@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] gcc: quiet Wattribute for no_sanitize("address")
Date: Mon, 26 Oct 2020 13:31:37 +0000 (GMT)	[thread overview]
Message-ID: <20201026133137.A40293939C37@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b9af5041bd5662748e060d7b716c18a224d91254

commit b9af5041bd5662748e060d7b716c18a224d91254
Author: rlibby <rlibby@FreeBSD.org>
Date:   Sat Dec 21 02:43:20 2019 +0000

    gcc: quiet Wattribute for no_sanitize("address")
    
    This is an unfortunate instance where the __has_attribute check does
    not function usefully.  Gcc does have the attribute, but for gcc it only
    applies to functions, not variables, and trying to apply it to a
    variable generates Wattribute.  So far we only apply the attribute to
    variables.  Only enable the attribute for clang, for now.
    
    Reviewed by:    Anton Rang <rang at acm.org>
    Sponsored by:   Dell EMC Isilon
    Differential Revision:  https://reviews.freebsd.org/D22875

Diff:
---
 newlib/libc/include/sys/cdefs.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index 1f2ce063d..1be994ffd 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -709,8 +709,12 @@
 /* Function should not be analyzed. */
 #define	__no_lock_analysis	__lock_annotate(no_thread_safety_analysis)
 
-/* Function or variable should not be sanitized, ie. by AddressSanitizer */
-#if __has_attribute(no_sanitize)
+/*
+ * Function or variable should not be sanitized, i.e. by AddressSanitizer.
+ * GCC has the nosanitize attribute, but as a function attribute only, and
+ * warns on use as a variable attribute.
+ */
+#if __has_attribute(no_sanitize) && defined(__clang__)
 #define __nosanitizeaddress	__attribute__((no_sanitize("address")))
 #else
 #define __nosanitizeaddress


                 reply	other threads:[~2020-10-26 13:31 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=20201026133137.A40293939C37@sourceware.org \
    --to=sh@sourceware.org \
    --cc=newlib-cvs@sourceware.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).