On Thu, Aug 12, 2021 at 07:07:00PM +0200, Jakub Jelinek via Gcc-patches wrote:
> On Thu, Aug 12, 2021 at 12:06:33PM -0400, Jason Merrill wrote:
> > Yes; if the standard says something nonsensical, I prefer to figure out
> > something more sensible to propose as a change.
> 
> Ok, so here it is implemented, so far tested only on the new testcases
> (but nothing else really uses the code that has changed since the last
> patch).  Also attached incremental diff (so that it is also clear
> what test behaviors changed).
> I'll of course bootstrap/regtest it full tonight.

Bootstrapped/regtested fine on both x86_64-linux and i686-linux.

> 2021-08-12  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR c++/101539
> gcc/c-family/
>       * c-common.h (enum rid): Add RID_IS_LAYOUT_COMPATIBLE.
>       * c-common.c (c_common_reswords): Add __is_layout_compatible.
> gcc/cp/
>       * cp-tree.h (enum cp_trait_kind): Add CPTK_IS_LAYOUT_COMPATIBLE.
>       (enum cp_built_in_function): Add CP_BUILT_IN_IS_CORRESPONDING_MEMBER.
>       (fold_builtin_is_corresponding_member, layout_compatible_type_p):
>       Declare.
>       * parser.c (cp_parser_primary_expression): Handle
>       RID_IS_LAYOUT_COMPATIBLE.
>       (cp_parser_trait_expr): Likewise.
>       * cp-objcp-common.c (names_builtin_p): Likewise.
>       * constraint.cc (diagnose_trait_expr): Handle
>       CPTK_IS_LAYOUT_COMPATIBLE.
>       * decl.c (cxx_init_decl_processing): Register
>       __builtin_is_corresponding_member builtin.
>       * constexpr.c (cxx_eval_builtin_function_call): Handle
>       CP_BUILT_IN_IS_CORRESPONDING_MEMBER builtin.
>       * semantics.c (is_corresponding_member_union,
>       is_corresponding_member_aggr, fold_builtin_is_corresponding_member):
>       New functions.
>       (trait_expr_value): Handle CPTK_IS_LAYOUT_COMPATIBLE.
>       (finish_trait_expr): Likewise.
>       * typeck.c (layout_compatible_type_p): New function.
>       * cp-gimplify.c (cp_gimplify_expr): Fold
>       CP_BUILT_IN_IS_CORRESPONDING_MEMBER.
>       (cp_fold): Likewise.
>       * tree.c (builtin_valid_in_constant_expr_p): Handle
>       CP_BUILT_IN_IS_CORRESPONDING_MEMBER.
>       * cxx-pretty-print.c (pp_cxx_trait_expression): Handle
>       CPTK_IS_LAYOUT_COMPATIBLE.
>       * class.c (remove_zero_width_bit_fields): Remove.
>       (layout_class_type): Don't call it.
> gcc/testsuite/
>       * g++.dg/cpp2a/is-corresponding-member1.C: New test.
>       * g++.dg/cpp2a/is-corresponding-member2.C: New test.
>       * g++.dg/cpp2a/is-corresponding-member3.C: New test.
>       * g++.dg/cpp2a/is-corresponding-member4.C: New test.
>       * g++.dg/cpp2a/is-corresponding-member5.C: New test.
>       * g++.dg/cpp2a/is-corresponding-member6.C: New test.
>       * g++.dg/cpp2a/is-corresponding-member7.C: New test.
>       * g++.dg/cpp2a/is-corresponding-member8.C: New test.
>       * g++.dg/cpp2a/is-layout-compatible1.C: New test.
>       * g++.dg/cpp2a/is-layout-compatible2.C: New test.
>       * g++.dg/cpp2a/is-layout-compatible3.C: New test.

        Jakub

Reply via email to