public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/aoliva/heads/testme)] enable __GXX_WEAK__ when using weak for one-only
Date: Fri, 25 Nov 2022 05:13:46 +0000 (GMT)	[thread overview]
Message-ID: <20221125051346.B31F5393BA54@sourceware.org> (raw)

https://gcc.gnu.org/g:79ccdb557f8207dfebc9a9fb541193deeec559f0

commit 79ccdb557f8207dfebc9a9fb541193deeec559f0
Author: Alexandre Oliva <oliva@gnu.org>
Date:   Fri Nov 25 02:06:46 2022 -0300

    enable __GXX_WEAK__ when using weak for one-only

Diff:
---
 gcc/c-family/c-cppbuiltin.cc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 333f3e138d6..15ef47c0c04 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -939,7 +939,15 @@ c_cpp_builtins (cpp_reader *pfile)
 
   if (c_dialect_cxx ())
     {
-      if (flag_weak && SUPPORTS_ONE_ONLY)
+      /* __GXX_WEAK__'s name is misleading, the documentation says it
+	 tests for one-only spuport, but SUPPORTS_ONE_ONLY is also
+	 slightly misleading, because weak symbols can be used for
+	 one-only support even if !SUPPORtS_ONE_ONLY.  Here we
+	 approximate the supprots_one_only() test that may clear
+	 flag_weak, but we use the flag_weak result instead of
+	 TARGET_SUPPORTS_WEAK, because the user may have disabled weak
+	 symbols with -fno-weak.  */
+      if (flag_weak || SUPPORTS_ONE_ONLY)
 	cpp_define (pfile, "__GXX_WEAK__=1");
       else
 	cpp_define (pfile, "__GXX_WEAK__=0");

             reply	other threads:[~2022-11-25  5:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-25  5:13 Alexandre Oliva [this message]
2022-11-25  6:34 Alexandre Oliva

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=20221125051346.B31F5393BA54@sourceware.org \
    --to=aoliva@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).