public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alex Coplan <alex.coplan@arm.com>
To: gcc-patches@gcc.gnu.org, Joseph Myers <joseph@codesourcery.com>,
	Jason Merrill <jason@redhat.com>, Nathan Sidwell <nathan@acm.org>,
	Iain Sandoe <iain@sandoe.co.uk>
Subject: Re: [PATCH v3][RFC] c-family: Implement __has_feature and __has_extension [PR60512]
Date: Thu, 17 Aug 2023 10:39:29 +0100	[thread overview]
Message-ID: <ZN3q0U4JbQcqRgHz@arm.com> (raw)
In-Reply-To: <ZMtxqMF1PQhWrWnZ@arm.com>

I'd like to ping this for review from C and C++ maintainers:
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626178.html

I probably should have dropped the RFC tag this time round as I think
the patch is nearly ready, I suppose we just need agreement on the
issues below: is there any GCC configuration where __thread can get
rejected (I don't know of one), and should cxx_binary_literals report as
a feature with -std=c2x?

Thanks,
Alex

On 03/08/2023 10:21, Alex Coplan via Gcc-patches wrote:
> Hi,
> 
> This patch implements clang's __has_feature and __has_extension in GCC.
> This is a v3 which addresses feedback for the v2 patch posted here:
> 
> https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626058.html
> 
> Main changes since v2:
>  - As per Jason's feedback, dropped the langhook in favour of
>    a function prototyped in c-family/c-common.h and implemented in
>    *-lang.cc for each frontend.
>  - Also dropped the callbacks as suggested, we now compute whether
>    features/extensions are available when __has_feature is first invoked,
>    and only add available features to the hash table (storing a boolean
>    to indicate whether a given identifier names a feature or an extension).
>  - Added many comments to top-level definitions.
>  - Generally polished and tidied up a bit.
> 
> As of this writing, there are still a couple of unresolved issues
> around cxx_binary_literals and TLS, see:
> https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626058.html
> 
> Bootstrapped/regtested on aarch64-linux-gnu and x86_64-apple-darwin.
> How does this version look?
> 
> Thanks,
> Alex
> 
> gcc/c-family/ChangeLog:
> 
> 	PR c++/60512
> 	* c-common.cc (struct hf_feature_info): New.
> 	(c_common_register_feature): New.
> 	(init_has_feature): New.
> 	(has_feature_p): New.
> 	* c-common.h (c_common_has_feature): New.
> 	(c_family_register_lang_features): New.
> 	(c_common_register_feature): New.
> 	(has_feature_p): New.
> 	(c_register_features): New.
> 	(cp_register_features): New.
> 	* c-lex.cc (init_c_lex): Plumb through has_feature callback.
> 	(c_common_has_builtin): Generalize and move common part ...
> 	(c_common_lex_availability_macro): ... here.
> 	(c_common_has_feature): New.
> 	* c-ppoutput.cc (init_pp_output): Plumb through has_feature.
> 
> gcc/c/ChangeLog:
> 
> 	PR c++/60512
> 	* c-lang.cc (c_family_register_lang_features): New.
> 	* c-objc-common.cc (struct c_feature_info): New.
> 	(c_register_features): New.
> 
> gcc/cp/ChangeLog:
> 
> 	PR c++/60512
> 	* cp-lang.cc (c_family_register_lang_features): New.
> 	* cp-objcp-common.cc (struct cp_feature_selector): New.
> 	(cp_feature_selector::has_feature): New.
> 	(struct cp_feature_info): New.
> 	(cp_register_features): New.
> 
> gcc/ChangeLog:
> 
> 	PR c++/60512
> 	* doc/cpp.texi: Document __has_{feature,extension}.
> 
> gcc/objc/ChangeLog:
> 
> 	PR c++/60512
> 	* objc-act.cc (struct objc_feature_info): New.
> 	(objc_nonfragile_abi_p): New.
> 	(objc_common_register_features): New.
> 	* objc-act.h (objc_common_register_features): New.
> 	* objc-lang.cc (c_family_register_lang_features): New.
> 
> gcc/objcp/ChangeLog:
> 
> 	PR c++/60512
> 	* objcp-lang.cc (c_family_register_lang_features): New.
> 
> libcpp/ChangeLog:
> 
> 	PR c++/60512
> 	* include/cpplib.h (struct cpp_callbacks): Add has_feature.
> 	(enum cpp_builtin_type): Add BT_HAS_{FEATURE,EXTENSION}.
> 	* init.cc: Add __has_{feature,extension}.
> 	* macro.cc (_cpp_builtin_macro_text): Handle
> 	BT_HAS_{FEATURE,EXTENSION}.
> 
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR c++/60512
> 	* c-c++-common/has-feature-common.c: New test.
> 	* g++.dg/ext/has-feature.C: New test.
> 	* gcc.dg/asan/has-feature-asan.c: New test.
> 	* gcc.dg/has-feature.c: New test.
> 	* gcc.dg/ubsan/has-feature-ubsan.c: New test.
> 	* obj-c++.dg/has-feature.mm: New test.
> 	* objc.dg/has-feature.m: New test.

  parent reply	other threads:[~2023-08-17  9:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03  9:21 Alex Coplan
2023-08-16 19:37 ` Iain Sandoe
2023-08-17  9:39 ` Alex Coplan [this message]
2023-09-05 10:33   ` Alex Coplan
2023-09-19 16:32 ` Jason Merrill

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=ZN3q0U4JbQcqRgHz@arm.com \
    --to=alex.coplan@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iain@sandoe.co.uk \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=nathan@acm.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).