Hi Alex,
> On 3 Aug 2023, at 10:21, Alex Coplan <alex.cop...@arm.com> wrote:
> 

> 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?

I smoke-tested this together with my current availability patch across a few
versions of Darwin and all is OK.  So fine for Objective-C/Darwin when the other
FE changes are approved,
thanks again for working on this,
Iain


> 
> 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.
> <patch.txt>

Reply via email to