[PATCH] coroutines: Do not assume parms are named [PR94752].
Hi As pointed out in the PR, parameters to user-defined coroutines might be unnamed. In that case, we must synthesize a name for the coroutine frame copy. tested on x86_64-darwin16 so far, OK if it passes regtest on x86_64-linux? thanks Iain gcc/cp/ChangeLog: 2020-04-25 Iain Sandoe * coroutines.cc (morph_fn_to_coro): Ensure that unnamed function params have a usable and distinct frame field name. gcc/testsuite/ChangeLog: 2020-04-25 Iain Sandoe * g++.dg/coroutines/pr94752.C: New test. --- gcc/cp/coroutines.cc | 11 +-- gcc/testsuite/g++.dg/coroutines/pr94752.C | 17 + 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/coroutines/pr94752.C diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 137d87bf294..ab1bdb9bcdb 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -3797,6 +3797,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) param_uses = new hash_map; bool lambda_p = LAMBDA_TYPE_P (DECL_CONTEXT (orig)); + unsigned no_name_parm = 0; for (tree arg = DECL_ARGUMENTS (orig); arg != NULL; arg = DECL_CHAIN (arg)) { @@ -3847,8 +3848,14 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) parm.lambda_cobj = false; parm.trivial_dtor = TYPE_HAS_TRIVIAL_DESTRUCTOR (parm.frame_type); - tree pname = DECL_NAME (arg); - char *buf = xasprintf ("__parm.%s", IDENTIFIER_POINTER (pname)); + char *buf; + if (DECL_NAME (arg)) + { + tree pname = DECL_NAME (arg); + buf = xasprintf ("__parm.%s", IDENTIFIER_POINTER (pname)); + } + else + buf = xasprintf ("__unnamed_parm.%d", no_name_parm++); parm.field_id = coro_make_frame_entry (&field_list, buf, actual_type, DECL_SOURCE_LOCATION (arg)); free (buf); diff --git a/gcc/testsuite/g++.dg/coroutines/pr94752.C b/gcc/testsuite/g++.dg/coroutines/pr94752.C new file mode 100644 index 000..7aa48ae8900 --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/pr94752.C @@ -0,0 +1,17 @@ +#include +using namespace std; + +struct task { +struct promise_type { +promise_type() {} +task get_return_object() { return {}; } +suspend_never initial_suspend() { return {}; } +suspend_never final_suspend() { return {}; } +void return_void() {} +void unhandled_exception() {} +}; +}; + +task foo(int) { +co_return; +} -- 2.24.1
[PATCH] c++, middle-end, rs6000: Fix C++17 ABI incompatibilities during class layout [PR94707]
Hi! As reported by Iain and David, powerpc-darwin and powerpc-aix* have C++14 vs. C++17 ABI incompatibilities which are not fixed by mere adding of cxx17_empty_base_field_p calls. Unlike the issues that were seen on other targets where the artificial empty base field affected function argument passing or returning of values, on these two targets the difference is during class layout, not afterwards (e.g. struct empty_base {}; struct S : public empty_base { unsigned long long l[2]; }; will have different __alignof__ (S) between C++14 and C++17 (or possibly with double instead of unsigned long long too)). The aim of the calls.c (cxx17_empty_base_field_p) was not to match random artificial fields with zero size, because they could be created by something else for some other reason, thus the DECL_SIZE is bitsize_zero but TYPE_SIZE is non-zero check. Unfortunately, during the class layout, the empty base fields have a different type, one which has zero size, so the predicate only works after the class is laid out completely. This patch adds a langhook, which will return true for those cases. It shouldn't be problematic with LTO, because lto1 should see only structures/classes that are already laid out, or if it does some structure layout, it won't be something that has C++17 empty base artificial fields. Tested with cross to powerpc-darwin12 on a simple testcase given from Iain, but otherwise untested. Iain/David, could you please test this on your targets? Ok for trunk? 2020-04-25 Jakub Jelinek PR target/94707 * langhooks.h (struct lang_hooks_for_decls): Add cxx17_empty_base_field_p member. * langhooks-def.h (LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_P): Define. (LANG_HOOKS_DECLS): Use it. * calls.c (cxx17_empty_base_field_p): Use langhooks.decls.cxx17_empty_base_field_p. * config/rs6000/rs6000.c (rs6000_special_round_type_align, darwin_rs6000_special_round_type_align): Skip cxx17_empty_base_field_p fields. cp/ * cp-objcp-common.h (cp_cxx17_empty_base_field_p): Declare. (LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_P): Redefine. * class.c (cp_cxx17_empty_base_field_p): New function. --- gcc/langhooks.h.jj 2020-03-17 13:50:52.262943386 +0100 +++ gcc/langhooks.h 2020-04-25 11:06:11.921931710 +0200 @@ -226,6 +226,9 @@ struct lang_hooks_for_decls /* True if this decl may be called via a sibcall. */ bool (*ok_for_sibcall) (const_tree); + /* True if this FIELD_DECL is C++17 empty base field. */ + bool (*cxx17_empty_base_field_p) (const_tree); + /* Return a tree for the actual data of an array descriptor - or NULL_TREE if original tree is not an array descriptor. If the second argument is true, only the TREE_TYPE is returned without generating a new tree. */ --- gcc/langhooks-def.h.jj 2020-01-12 11:54:36.670409531 +0100 +++ gcc/langhooks-def.h 2020-04-25 11:06:03.300061347 +0200 @@ -241,6 +241,7 @@ extern tree lhd_unit_size_without_reusab #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl #define LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS NULL #define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall +#define LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_Phook_bool_const_tree_false #define LANG_HOOKS_OMP_ARRAY_DATA hook_tree_tree_bool_null #define LANG_HOOKS_OMP_IS_ALLOCATABLE_OR_PTR hook_bool_const_tree_false #define LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT hook_tree_tree_bool_null @@ -269,6 +270,7 @@ extern tree lhd_unit_size_without_reusab LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \ LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS, \ LANG_HOOKS_DECL_OK_FOR_SIBCALL, \ + LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_P, \ LANG_HOOKS_OMP_ARRAY_DATA, \ LANG_HOOKS_OMP_IS_ALLOCATABLE_OR_PTR, \ LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT, \ --- gcc/calls.c.jj 2020-04-22 16:44:30.765946555 +0200 +++ gcc/calls.c 2020-04-25 11:14:45.038217088 +0200 @@ -6275,8 +6275,9 @@ cxx17_empty_base_field_p (const_tree fie && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)) && DECL_SIZE (field) && integer_zerop (DECL_SIZE (field)) - && TYPE_SIZE (TREE_TYPE (field)) - && !integer_zerop (TYPE_SIZE (TREE_TYPE (field; + && ((TYPE_SIZE (TREE_TYPE (field)) + && !integer_zerop (TYPE_SIZE (TREE_TYPE (field + || lang_hooks.decls.cxx17_empty_base_field_p (field))); } /* Tell the garbage collector about GTY markers in this source file. */ --- gcc/config/rs6000/rs6000.c.jj 2020-04-22 16:43:14.913087731 +0200 +++ gcc/config/rs6000/rs6000.c 2020-04-25 11:16:01.536067016 +0200 @@ -7192,7 +7192,9 @@ rs6000_special_round_type_align (tree ty tree field = TYPE_FIELDS (type); /* Skip all non field decls */ - while (field != NULL && TREE_CODE (field) != FIELD_DECL) + while (field != NULL +&& (TREE_CODE (field) != FIELD_DECL +|| cxx17_empty_base_field_p (field))) field = DEC
[patch, fortran, committed] Fix PR 94578
Hello world, rather than touch 50% of the files in our libfortran subdirectory, I opted for the simple and obvious way - if the RHS is a pointer which may have a span, just create a temporary. (We're also qutie close to a release candidate if I count the P1 regressions correctly, so this is not a time for big changes). I think we can (and should) revisit this for gcc 11. Committed after regression-testing. I will backport to gcc 9 and gcc 8 soon. Regards Thomas Fix PR 94578. Our intrinsics do not handle spans on their return values (yet), so this creates a temporary for subref array pointers. 2020-04-25 Thomas Koenig 2020-04-25 Thomas Koenig PR fortran/94578 * trans-expr.c (arrayfunc_assign_needs_temporary): If the LHS is a subref pointer, we also need a temporary. 2020-04-25 Thomas Koenig PR fortran/94578 * gfortran.dg/pointer_assign_14.f90: New test. * gfortran.dg/pointer_assign_15.f90: New test. diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index fdca9cc5539..030edc1e5ce 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -9823,9 +9823,13 @@ arrayfunc_assign_needs_temporary (gfc_expr * expr1, gfc_expr * expr2) /* If we have reached here with an intrinsic function, we do not need a temporary except in the particular case that reallocation - on assignment is active and the lhs is allocatable and a target. */ + on assignment is active and the lhs is allocatable and a target, + or a pointer which may be a subref pointer. FIXME: The last + condition can go away when we use span in the intrinsics + directly.*/ if (expr2->value.function.isym) -return (flag_realloc_lhs && sym->attr.allocatable && sym->attr.target); +return (flag_realloc_lhs && sym->attr.allocatable && sym->attr.target) + || (sym->attr.pointer && sym->attr.subref_array_pointer); /* If the LHS is a dummy, we need a temporary if it is not INTENT(OUT). */ diff --git a/gcc/testsuite/gfortran.dg/pointer_assign_14.f90 b/gcc/testsuite/gfortran.dg/pointer_assign_14.f90 new file mode 100644 index 000..b06dd841bcc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pointer_assign_14.f90 @@ -0,0 +1,19 @@ +! { dg-do run } +! PR fortran/94578 +! This used to give wrong results. +program main + implicit none + type foo + integer :: x, y,z + end type foo + integer :: i + integer, dimension(:), pointer :: array1d + type(foo), dimension(2), target :: solution + integer, dimension(2,2) :: a + data a /1,2,3,4/ + solution%x = -10 + solution%y = -20 + array1d => solution%x + array1d = maxval(a,dim=1) + if (any (array1d /= [2,4])) stop 1 +end program main diff --git a/gcc/testsuite/gfortran.dg/pointer_assign_15.f90 b/gcc/testsuite/gfortran.dg/pointer_assign_15.f90 new file mode 100644 index 000..7c2885910cf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pointer_assign_15.f90 @@ -0,0 +1,18 @@ +! { dg-do run } +! PR fortran/94578 +! This used to give wrong results. Original test case by Jan-Willem +! Blokland. +program main + implicit none + type foo + integer :: x, y + end type foo + integer :: i + integer, dimension (2,2) :: array2d + integer, dimension(:), pointer :: array1d + type(foo), dimension(2*2), target :: solution + data array2d /1,2,3,4/ + array1d => solution%x + array1d = reshape (source=array2d, shape=shape(array1d)) + if (any (array1d /= [1,2,3,4])) stop 1 +end program main
Re: [PATCH] c++, middle-end, rs6000: Fix C++17 ABI incompatibilities during class layout [PR94707]
Hi! On Sat, Apr 25, 2020 at 12:03:10PM +0200, Jakub Jelinek wrote: > As reported by Iain and David, powerpc-darwin and powerpc-aix* have C++14 > vs. C++17 ABI incompatibilities which are not fixed by mere adding of > cxx17_empty_base_field_p calls. Unlike the issues that were seen on other > targets where the artificial empty base field affected function argument > passing or returning of values, on these two targets the difference is > during class layout, not afterwards (e.g. > struct empty_base {}; > struct S : public empty_base { unsigned long long l[2]; }; > will have different __alignof__ (S) between C++14 and C++17 (or possibly > with double instead of unsigned long long too)). > > The aim of the calls.c (cxx17_empty_base_field_p) was not to match random > artificial fields with zero size, because they could be created by something > else for some other reason, thus the DECL_SIZE is bitsize_zero but TYPE_SIZE > is non-zero check. Unfortunately, during the class layout, the empty base > fields have a different type, one which has zero size, so the predicate only > works after the class is laid out completely. > > This patch adds a langhook, which will return true for those cases. It > shouldn't be problematic with LTO, because lto1 should see only > structures/classes that are already laid out, or if it does some structure > layout, it won't be something that has C++17 empty base artificial fields. Ah okay. Maybe this *whole* thing should have been a langhook? > Tested with cross to powerpc-darwin12 on a simple testcase given from Iain, > but otherwise untested. > Iain/David, could you please test this on your targets? The rs6000 part is fine (and the rest looks good, too). If Iain and David agree of course :-) Segher > 2020-04-25 Jakub Jelinek > > PR target/94707 > * langhooks.h (struct lang_hooks_for_decls): Add > cxx17_empty_base_field_p member. > * langhooks-def.h (LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_P): Define. > (LANG_HOOKS_DECLS): Use it. > * calls.c (cxx17_empty_base_field_p): Use > langhooks.decls.cxx17_empty_base_field_p. > * config/rs6000/rs6000.c (rs6000_special_round_type_align, > darwin_rs6000_special_round_type_align): Skip cxx17_empty_base_field_p > fields. > cp/ > * cp-objcp-common.h (cp_cxx17_empty_base_field_p): Declare. > (LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_P): Redefine. > * class.c (cp_cxx17_empty_base_field_p): New function.
[PATCH] coroutines: Fix handling of non-class coroutine returns [PR94759]
Hi >From the standard: The header defines the primary template coroutine_traits such that if ArgTypes is a parameter pack of types and if the qualified-id R::promise_type is valid and denotes a type, then coroutine_traits has the following publicly accessible member: using promise_type = typename R::promise_type; — however, this should not prevent more specialised cases and the code in the PR (the testcase in the following patch) should be accepted, but is currently rejected with: 'error: coroutine return type ‘void’ is not a class' This is because I applied the check for non-class-ness of the return value in the wrong place; it needs to be carried out in a SFINAE context. The following patch removes the restriction in the traits template instantiation and allows for the case that the ramp function could return void. Jonathan provided a draft of a change to the header to implement the required functionality, which has been incorporated. == tested on x86_64-darwin, OK for master if the testing passes regstrap on x86-64-linux? thanks Iain gcc/cp/ChangeLog: 2020-04-23 Iain Sandoe PR c++/94759 * coroutines.cc (coro_promise_type_found_p): Do not exclude non-classes here (this needs to be handled in the coroutine header). (morph_fn_to_coro): Allow for the case where the coroutine returns void. gcc/testsuite/ChangeLog: 2020-04-25 Iain Sandoe PR c++/94759 * g++.dg/coroutines/coro-bad-alloc-00-bad-op-new.C: Adjust for updated error messages. * g++.dg/coroutines/coro-bad-alloc-01-bad-op-del.C: Likewise. * g++.dg/coroutines/coro-bad-alloc-02-no-op-new-nt.C: Likewise. * g++.dg/coroutines/coro-missing-promise.C: Likewise. * g++.dg/coroutines/pr93458-5-bad-coro-type.C: Liekwise. * g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C: New test. libstdc++-v3/ChangeLog: 2020-04-25 Jonathan Wakely Iain Sandoe PR c++/94759 * include/std/coroutine: Implement handing for non- class coroutine return types. --- gcc/cp/coroutines.cc | 102 +- .../coroutines/coro-bad-alloc-00-bad-op-new.C | 2 +- .../coroutines/coro-bad-alloc-01-bad-op-del.C | 2 +- .../coro-bad-alloc-02-no-op-new-nt.C | 2 +- .../g++.dg/coroutines/coro-missing-promise.C | 2 - .../coroutines/pr93458-5-bad-coro-type.C | 4 +- .../torture/co-ret-17-void-ret-coro.C | 57 ++ libstdc++-v3/include/std/coroutine| 15 ++- 8 files changed, 122 insertions(+), 64 deletions(-) create mode 100644 gcc/testsuite/g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 4f254b7fd10..db6f16b3e21 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -441,18 +441,6 @@ coro_promise_type_found_p (tree fndecl, location_t loc) { /* Get the coroutine traits template class instance for the function signature we have - coroutine_traits */ - tree return_type = TREE_TYPE (TREE_TYPE (fndecl)); - if (!CLASS_TYPE_P (return_type)) - { - /* It makes more sense to show the function header for this, even -though we will have encountered it when processing a keyword. -Only emit the error once, not for every keyword we encounter. */ - if (!coro_info->coro_ret_type_error_emitted) - error_at (DECL_SOURCE_LOCATION (fndecl), "coroutine return type" - " %qT is not a class", return_type); - coro_info->coro_ret_type_error_emitted = true; - return false; - } tree templ_class = instantiate_coro_traits (fndecl, loc); @@ -3500,9 +3488,6 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) if (!coro_function_valid_p (orig)) return false; - /* The ramp function does return a value. */ - current_function_returns_value = 1; - /* We can't validly get here with an empty statement list, since there's no way for the FE to decide it's a coroutine in the absence of any code. */ tree fnbody = pop_stmt_list (DECL_SAVED_TREE (orig)); @@ -3575,7 +3560,6 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) 1. Types we already know. */ tree fn_return_type = TREE_TYPE (TREE_TYPE (orig)); - gcc_assert (!VOID_TYPE_P (fn_return_type)); tree handle_type = get_coroutine_handle_type (orig); tree promise_type = get_coroutine_promise_type (orig); @@ -3927,33 +3911,27 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) control to the caller of the coroutine and the return value is obtained by a call to T::get_return_object_on_allocation_failure(), where T is the promise type. */ - tree cfra_label - = create_named_label_with_ctx (fn_start, "coro.frame.active", - current_scope ()); - tree
[PATCH] coroutines: Pass class ref to traits lookup and promise allocator [PR94760]
(WAS [PATCH] coroutines: Handle lambda capture objects in the way as clang.) I am sorry to mess you around on this. You had approved a previous patch, which I then withdrew because of the confusion about what each implementation was doing (you were on that long email thread). Now that MSVC and clang folks, have clarified things + we have a testcase that demonstrates rejecting valid code .. I’d like to ask for the following updated patch to be approved, and there’s a PR tracking the rejects-valid. Tested locally, OK after re-resting on x86-64-linux? thanks Iain This will be followed up with one implementing the change for lambda object pointers. Iain Sandoe wrote: > Iain Sandoe wrote: > >> Nathan Sidwell wrote: >> >>> On 4/22/20 8:48 AM, Iain Sandoe wrote: Hi, There is no PR for this, at present, but the implementation of clang and GCC's handling of lambda capture object implicit parms is currently different. There is still some discussion about 'correct' interpretation of the standard - but in the short-term it is probably best to have consistent implementations - even if those subsequently turn out to be 'consistently wrong'. >>> >>> Agreed, the std is at best ambigiuous in this area, we should aim for >>> implementation agreement. >> >> following more discussion amongst WG21 members, it appears that there is >> still >> some confusion over the status of other implementations, and it may well be >> that >> clang will be updated to follow the pattern that GCC is currently >> implementing. >> >> In light of this, perhaps it’s best to withdraw this patch for now. > > I think we should apply the following, pending the resolution of the ‘correct’ > action for the lambda closure object. This brings GCC into line with clang > for the > handing of ‘this’ in method coroutines, but leaves it untouched for lambda > closure > object pointers. We changed the argument passed to the promise parameter preview to match a reference to *this. However to be consistent with the other ports, we do need to match the reference transformation in the traits lookup and the promise allocator lookup. gcc/cp/ChangeLog: 2020-04-25 Iain Sandoe PR c++/94760 * coroutines.cc (instantiate_coro_traits): Pass a reference to object type rather than a pointer type for 'this', for method coroutines. (struct param_info): Add a field to hold that the parm is a lambda closure pointer. (morph_fn_to_coro): Check for lambda closure pointers in the args. Use a reference to *this when building the args list for the promise allocator lookup. gcc/testsuite/ChangeLog: 2020-04-25 Iain Sandoe PR c++/94760 * g++.dg/coroutines/pr94760-mismatched-traits-and-promise-prev.C: New test. --- gcc/cp/coroutines.cc | 52 +-- ...9-mismatched-traits-and-promise-prev.C | 29 +++ 2 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/coroutines/pr9-mismatched-traits-and-promise-prev.C diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 4f254b7fd10..c80a3b716b2 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -296,14 +296,25 @@ instantiate_coro_traits (tree fndecl, location_t kw) type. */ tree functyp = TREE_TYPE (fndecl); + tree arg = DECL_ARGUMENTS (fndecl); + bool lambda_p = LAMBDA_TYPE_P (DECL_CONTEXT (fndecl)); tree arg_node = TYPE_ARG_TYPES (functyp); tree argtypes = make_tree_vec (list_length (arg_node)-1); unsigned p = 0; while (arg_node != NULL_TREE && !VOID_TYPE_P (TREE_VALUE (arg_node))) { - TREE_VEC_ELT (argtypes, p++) = TREE_VALUE (arg_node); + if (is_this_parameter (arg) && !lambda_p) + { + /* We pass a reference to *this to the param preview. */ + tree ct = TREE_TYPE (TREE_TYPE (arg)); + TREE_VEC_ELT (argtypes, p++) = cp_build_reference_type (ct, false); + } + else + TREE_VEC_ELT (argtypes, p++) = TREE_VALUE (arg_node); + arg_node = TREE_CHAIN (arg_node); + arg = DECL_CHAIN (arg); } tree argtypepack = cxx_make_type (TYPE_ARGUMENT_PACK); @@ -1766,6 +1777,7 @@ struct param_info bool pt_ref; /* Was a pointer to object. */ bool trivial_dtor; /* The frame type has a trivial DTOR. */ bool this_ptr; /* Is 'this' */ + bool lambda_cobj; /* Lambda capture object */ }; struct local_var_info @@ -3652,6 +3664,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) The second two entries start out empty - and only get populated when we see uses. */ param_uses = new hash_map; + bool lambda_p = LAMBDA_TYPE_P (DECL_CONTEXT (orig)); for (tree arg = DECL_ARGUMENTS (orig); arg != NULL; arg = DECL_CHAIN (arg)) @@ -3691,7 +3704,17 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destr
Re: [PATCH] coroutines: Fix handling of non-class coroutine returns [PR94759]
On 25/04/20 14:49 +0100, Iain Sandoe wrote: Hi From the standard: The header defines the primary template coroutine_traits such that if ArgTypes is a parameter pack of types and if the qualified-id R::promise_type is valid and denotes a type, then coroutine_traits has the following publicly accessible member: using promise_type = typename R::promise_type; — however, this should not prevent more specialised cases and the code in the PR (the testcase in the following patch) should be accepted, but is currently rejected with: 'error: coroutine return type ‘void’ is not a class' This is because I applied the check for non-class-ness of the return value in the wrong place; it needs to be carried out in a SFINAE context. The following patch removes the restriction in the traits template instantiation and allows for the case that the ramp function could return void. Jonathan provided a draft of a change to the header to implement the required functionality, which has been incorporated. == tested on x86_64-darwin, OK for master if the testing passes regstrap on x86-64-linux? thanks Iain gcc/cp/ChangeLog: 2020-04-23 Iain Sandoe PR c++/94759 * coroutines.cc (coro_promise_type_found_p): Do not exclude non-classes here (this needs to be handled in the coroutine header). (morph_fn_to_coro): Allow for the case where the coroutine returns void. gcc/testsuite/ChangeLog: 2020-04-25 Iain Sandoe PR c++/94759 * g++.dg/coroutines/coro-bad-alloc-00-bad-op-new.C: Adjust for updated error messages. * g++.dg/coroutines/coro-bad-alloc-01-bad-op-del.C: Likewise. * g++.dg/coroutines/coro-bad-alloc-02-no-op-new-nt.C: Likewise. * g++.dg/coroutines/coro-missing-promise.C: Likewise. * g++.dg/coroutines/pr93458-5-bad-coro-type.C: Liekwise. * g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C: New test. libstdc++-v3/ChangeLog: 2020-04-25 Jonathan Wakely Iain Sandoe PR c++/94759 * include/std/coroutine: Implement handing for non- class coroutine return types. --- gcc/cp/coroutines.cc | 102 +- .../coroutines/coro-bad-alloc-00-bad-op-new.C | 2 +- .../coroutines/coro-bad-alloc-01-bad-op-del.C | 2 +- .../coro-bad-alloc-02-no-op-new-nt.C | 2 +- .../g++.dg/coroutines/coro-missing-promise.C | 2 - .../coroutines/pr93458-5-bad-coro-type.C | 4 +- .../torture/co-ret-17-void-ret-coro.C | 57 ++ libstdc++-v3/include/std/coroutine| 15 ++- 8 files changed, 122 insertions(+), 64 deletions(-) create mode 100644 gcc/testsuite/g++.dg/coroutines/torture/co-ret-17-void-ret-coro.C diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 4f254b7fd10..db6f16b3e21 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -441,18 +441,6 @@ coro_promise_type_found_p (tree fndecl, location_t loc) { /* Get the coroutine traits template class instance for the function signature we have - coroutine_traits */ - tree return_type = TREE_TYPE (TREE_TYPE (fndecl)); - if (!CLASS_TYPE_P (return_type)) - { - /* It makes more sense to show the function header for this, even -though we will have encountered it when processing a keyword. -Only emit the error once, not for every keyword we encounter. */ - if (!coro_info->coro_ret_type_error_emitted) - error_at (DECL_SOURCE_LOCATION (fndecl), "coroutine return type" - " %qT is not a class", return_type); - coro_info->coro_ret_type_error_emitted = true; - return false; - } tree templ_class = instantiate_coro_traits (fndecl, loc); @@ -3500,9 +3488,6 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) if (!coro_function_valid_p (orig)) return false; - /* The ramp function does return a value. */ - current_function_returns_value = 1; - /* We can't validly get here with an empty statement list, since there's no way for the FE to decide it's a coroutine in the absence of any code. */ tree fnbody = pop_stmt_list (DECL_SAVED_TREE (orig)); @@ -3575,7 +3560,6 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) 1. Types we already know. */ tree fn_return_type = TREE_TYPE (TREE_TYPE (orig)); - gcc_assert (!VOID_TYPE_P (fn_return_type)); tree handle_type = get_coroutine_handle_type (orig); tree promise_type = get_coroutine_promise_type (orig); @@ -3927,33 +3911,27 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) control to the caller of the coroutine and the return value is obtained by a call to T::get_return_object_on_allocation_failure(), where T is the promise type. */ - tree cfra_label - = create_named_label_with_ctx (fn_start, "coro.frame.active", - current_scope
Re: [PATCH] Enable Intel CET in liblto_plugin.so on Intel CET enabled host
On April 24, 2020 9:31:58 PM GMT+02:00, "H.J. Lu" wrote: >Since ld is Intel CET enabled on Intel CET enabled host, dlopen fails >on >liblto_plugin.so if it isn't Intel CET enabled. Add GCC_CET_HOST_FLAGS >to cet.m4, use it in libiberty and lto-plugin to always enable Intel >CET in liblto_plugin.so on Intel CET enabled host. > >On Linux/x86 host, enable Intel CET by default if assembler and >compiler >support Intel CET so that generated the liblto_plugin.so can be used on >both CET and non-CET machines. It is an error to disable Intel CET in >liblto_plugin.so on Intel CET enabled host. > >OK for master? OK I guess. What about libcc1 used by gdb? What about libjit? Richard. >Thanks. > >H.J. >--- >config/ > > PR bootstrap/94739 > * cet.m4 (GCC_CET_HOST_FLAGS): New. > >libiberty/ > > PR bootstrap/94739 > * Makefile.in (COMPILE.c): Add @CET_HOST_FLAGS@. > (configure_deps): Add $(srcdir)/../config/cet.m4 and > $(srcdir)/../config/enable.m4. > * aclocal.m4: Include ../config/cet.m4 and ../config/enable.m4. > * configure.ac: Add GCC_CET_HOST_FLAGS(CET_HOST_FLAGS) and > AC_SUBST(CET_HOST_FLAGS). > * configure: Regenerated. > >lto-plugin/ > > PR bootstrap/94739 > * Makefile.am (AM_CFLAGS): Add $(CET_HOST_FLAGS). > * configure.ac: Add GCC_CET_HOST_FLAGS(CET_HOST_FLAGS) and > AC_SUBST(CET_HOST_FLAGS). > * Makefile.in: Regenerated. > * aclocal.m4: Likewise. > * configure: Likewise. >--- > config/cet.m4 | 94 + > libiberty/Makefile.in | 5 +- > libiberty/aclocal.m4| 2 + > libiberty/configure | 145 ++ > libiberty/configure.ac | 3 + > lto-plugin/Makefile.am | 2 +- > lto-plugin/Makefile.in | 5 +- > lto-plugin/aclocal.m4 | 2 + > lto-plugin/configure| 149 +++- > lto-plugin/configure.ac | 3 + > 10 files changed, 405 insertions(+), 5 deletions(-) > >diff --git a/config/cet.m4 b/config/cet.m4 >index b53c1bbd5cd..8b9e01fd492 100644 >--- a/config/cet.m4 >+++ b/config/cet.m4 >@@ -48,3 +48,97 @@ else > AC_MSG_RESULT([no]) > fi > ]) >+ >+dnl >+dnl GCC_CET_HOST_FLAGS >+dnl(SHELL-CODE_HANDLER) >+dnl >+AC_DEFUN([GCC_CET_HOST_FLAGS],[dnl >+GCC_ENABLE(cet, auto, ,[enable Intel CET in host libraries], >+ permit yes|no|auto) >+AC_MSG_CHECKING([for CET support]) >+ >+case "$host" in >+ i[[34567]]86-*-linux* | x86_64-*-linux*) >+may_have_cet=yes >+save_CFLAGS="$CFLAGS" >+CFLAGS="$CFLAGS -fcf-protection" >+case "$enable_cet" in >+ auto) >+ # Check if target supports multi-byte NOPs >+ # and if assembler supports CET insn. >+ AC_COMPILE_IFELSE( >+ [AC_LANG_PROGRAM( >+[], >+[ >+#if !defined(__SSE2__) >+#error target does not support multi-byte NOPs >+#else >+asm ("setssbsy"); >+#endif >+])], >+ [enable_cet=yes], >+ [enable_cet=no]) >+ ;; >+ yes) >+ # Check if assembler supports CET. >+ AC_COMPILE_IFELSE( >+ [AC_LANG_PROGRAM( >+[], >+[asm ("setssbsy");])], >+ [], >+ [AC_MSG_ERROR([assembler with CET support is required for >--enable-cet])]) >+ ;; >+esac >+CFLAGS="$save_CFLAGS" >+;; >+ *) >+may_have_cet=no >+enable_cet=no >+;; >+esac >+ >+if test x$may_have_cet = xyes; then >+ save_LDFLAGS="$LDFLAGS" >+ LDFLAGS="$LDFLAGS -Wl,-z,ibt,-z,shstk" >+ AC_TRY_RUN([ >+static void >+foo (void) >+{ >+} >+ >+static void >+__attribute__ ((noinline, noclone)) >+xxx (void (*f) (void)) >+{ >+ f (); >+} >+ >+static void >+__attribute__ ((noinline, noclone)) >+bar (void) >+{ >+ xxx (foo); >+} >+ >+int >+main () >+{ >+ bar (); >+ return 0; >+} >+ ], >+ [have_cet=no], >+ [have_cet=yes]) >+ LDFLAGS="$save_LDFLAGS" >+ if test x$enable_cet = xno -a x$have_cet = xyes; then >+AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled >host]) >+ fi >+fi >+if test x$enable_cet = xyes; then >+ $1="-fcf-protection" >+ AC_MSG_RESULT([yes]) >+else >+ AC_MSG_RESULT([no]) >+fi >+]) >diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in >index fe738d0db43..d6b302e02fd 100644 >--- a/libiberty/Makefile.in >+++ b/libiberty/Makefile.in >@@ -112,7 +112,8 @@ installcheck: installcheck-subdir > INCDIR=$(srcdir)/$(MULTISRCTOP)../include > > COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR) \ >- $(HDEFINES) @ac_libiberty_warn_cflags@ -D_GNU_SOURCE >+ $(HDEFINES) @ac_libiberty_warn_cflags@ -D_GNU_SOURCE \ >+ @CET_HOST_FLAGS@ > > # Just to make sure we don't use a built-in rule with VPATH > .c.$(objext): >@@ -481,6 +482,8 @@ config.status: $(srcdir)/configure > AUTOCONF = autoconf > configure_deps = $(srcdir)/aclocal.m4 \ > $(srcdir)/../config/acx.m4 \ >+ $(srcdir)/../config/cet.m4 \ >+ $(srcdir)/../config/enable.m4 \ > $(srcdir)/../config/no-executables.m4 \ >
Re: [PATCH] Enable Intel CET in liblto_plugin.so on Intel CET enabled host
On Sat, Apr 25, 2020 at 9:29 AM Richard Biener wrote: > > On April 24, 2020 9:31:58 PM GMT+02:00, "H.J. Lu" wrote: > >Since ld is Intel CET enabled on Intel CET enabled host, dlopen fails > >on > >liblto_plugin.so if it isn't Intel CET enabled. Add GCC_CET_HOST_FLAGS > >to cet.m4, use it in libiberty and lto-plugin to always enable Intel > >CET in liblto_plugin.so on Intel CET enabled host. > > > >On Linux/x86 host, enable Intel CET by default if assembler and > >compiler > >support Intel CET so that generated the liblto_plugin.so can be used on > >both CET and non-CET machines. It is an error to disable Intel CET in > >liblto_plugin.so on Intel CET enabled host. > > > >OK for master? > > OK I guess. What about libcc1 used by gdb? What about libjit? I will check in my patch. For GCC 11, I will submit patches to enable CET in libphobos, zlib, libffi, libgo, libcc1 and libjit. Thanks. > Richard. > > > >Thanks. > > > >H.J. > >--- > >config/ > > > > PR bootstrap/94739 > > * cet.m4 (GCC_CET_HOST_FLAGS): New. > > > >libiberty/ > > > > PR bootstrap/94739 > > * Makefile.in (COMPILE.c): Add @CET_HOST_FLAGS@. > > (configure_deps): Add $(srcdir)/../config/cet.m4 and > > $(srcdir)/../config/enable.m4. > > * aclocal.m4: Include ../config/cet.m4 and ../config/enable.m4. > > * configure.ac: Add GCC_CET_HOST_FLAGS(CET_HOST_FLAGS) and > > AC_SUBST(CET_HOST_FLAGS). > > * configure: Regenerated. > > > >lto-plugin/ > > > > PR bootstrap/94739 > > * Makefile.am (AM_CFLAGS): Add $(CET_HOST_FLAGS). > > * configure.ac: Add GCC_CET_HOST_FLAGS(CET_HOST_FLAGS) and > > AC_SUBST(CET_HOST_FLAGS). > > * Makefile.in: Regenerated. > > * aclocal.m4: Likewise. > > * configure: Likewise. > >--- > > config/cet.m4 | 94 + > > libiberty/Makefile.in | 5 +- > > libiberty/aclocal.m4| 2 + > > libiberty/configure | 145 ++ > > libiberty/configure.ac | 3 + > > lto-plugin/Makefile.am | 2 +- > > lto-plugin/Makefile.in | 5 +- > > lto-plugin/aclocal.m4 | 2 + > > lto-plugin/configure| 149 +++- > > lto-plugin/configure.ac | 3 + > > 10 files changed, 405 insertions(+), 5 deletions(-) > > > >diff --git a/config/cet.m4 b/config/cet.m4 > >index b53c1bbd5cd..8b9e01fd492 100644 > >--- a/config/cet.m4 > >+++ b/config/cet.m4 > >@@ -48,3 +48,97 @@ else > > AC_MSG_RESULT([no]) > > fi > > ]) > >+ > >+dnl > >+dnl GCC_CET_HOST_FLAGS > >+dnl(SHELL-CODE_HANDLER) > >+dnl > >+AC_DEFUN([GCC_CET_HOST_FLAGS],[dnl > >+GCC_ENABLE(cet, auto, ,[enable Intel CET in host libraries], > >+ permit yes|no|auto) > >+AC_MSG_CHECKING([for CET support]) > >+ > >+case "$host" in > >+ i[[34567]]86-*-linux* | x86_64-*-linux*) > >+may_have_cet=yes > >+save_CFLAGS="$CFLAGS" > >+CFLAGS="$CFLAGS -fcf-protection" > >+case "$enable_cet" in > >+ auto) > >+ # Check if target supports multi-byte NOPs > >+ # and if assembler supports CET insn. > >+ AC_COMPILE_IFELSE( > >+ [AC_LANG_PROGRAM( > >+[], > >+[ > >+#if !defined(__SSE2__) > >+#error target does not support multi-byte NOPs > >+#else > >+asm ("setssbsy"); > >+#endif > >+])], > >+ [enable_cet=yes], > >+ [enable_cet=no]) > >+ ;; > >+ yes) > >+ # Check if assembler supports CET. > >+ AC_COMPILE_IFELSE( > >+ [AC_LANG_PROGRAM( > >+[], > >+[asm ("setssbsy");])], > >+ [], > >+ [AC_MSG_ERROR([assembler with CET support is required for > >--enable-cet])]) > >+ ;; > >+esac > >+CFLAGS="$save_CFLAGS" > >+;; > >+ *) > >+may_have_cet=no > >+enable_cet=no > >+;; > >+esac > >+ > >+if test x$may_have_cet = xyes; then > >+ save_LDFLAGS="$LDFLAGS" > >+ LDFLAGS="$LDFLAGS -Wl,-z,ibt,-z,shstk" > >+ AC_TRY_RUN([ > >+static void > >+foo (void) > >+{ > >+} > >+ > >+static void > >+__attribute__ ((noinline, noclone)) > >+xxx (void (*f) (void)) > >+{ > >+ f (); > >+} > >+ > >+static void > >+__attribute__ ((noinline, noclone)) > >+bar (void) > >+{ > >+ xxx (foo); > >+} > >+ > >+int > >+main () > >+{ > >+ bar (); > >+ return 0; > >+} > >+ ], > >+ [have_cet=no], > >+ [have_cet=yes]) > >+ LDFLAGS="$save_LDFLAGS" > >+ if test x$enable_cet = xno -a x$have_cet = xyes; then > >+AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled > >host]) > >+ fi > >+fi > >+if test x$enable_cet = xyes; then > >+ $1="-fcf-protection" > >+ AC_MSG_RESULT([yes]) > >+else > >+ AC_MSG_RESULT([no]) > >+fi > >+]) > >diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in > >index fe738d0db43..d6b302e02fd 100644 > >--- a/libiberty/Makefile.in > >+++ b/libiberty/Makefile.in > >@@ -112,7 +112,8 @@ installcheck: installcheck-subdir > > INCDIR=$(srcdir)/$(MULTISRCTOP)../include > > > > COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR) \ > >-
Re: [PATCH] c++, middle-end, rs6000: Fix C++17 ABI incompatibilities during class layout [PR94707]
On Sat, Apr 25, 2020 at 08:48:09AM -0500, Segher Boessenkool wrote: > > This patch adds a langhook, which will return true for those cases. It > > shouldn't be problematic with LTO, because lto1 should see only > > structures/classes that are already laid out, or if it does some structure > > layout, it won't be something that has C++17 empty base artificial fields. > > Ah okay. Maybe this *whole* thing should have been a langhook? It can't be because of LTO. Jakub
Re: [PATCH v5 GCC] libffi/test: Fix compilation for build sysroot
On Wed, 22 Apr 2020, Jeff Law wrote: > > libffi/ > > * Makefile.am (DISTCLEANFILES): New variable. > > * configure.ac: Produce `local.exp'. > > * Makefile.in: Regenerate. > > * configure: Regenerate. > > * testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): New > > variable. > > * testsuite/Makefile.in: Regenerate. > OK > jeff Committed now then, according to schedule, thanks for your review. We may revisit the backport of improvements I previously proposed when/if the upstream libffi maintainer decides to accept them. Maciej
Re: [committed] d: Merge upstream dmd 09db0c41e, druntime e68a5ae3.
Hi! On Sat, Apr 25, 2020 at 02:20:19AM +0200, Iain Buclaw via Gcc-patches wrote: > +// Parse DoubleDoubles as a pair of doubles. > +// The layout of the type is: > +// > +// [1| 7 | 56 ][ 8| 56 ] > +// [S| Exp | Fraction (hi) ][ Unused | Fraction (low) ] > +// > +// We can get the least significant bits by subtracting the IEEE > +// double precision portion from the real value. That's not correct. There is no "Unused" field, and the lower fraction is not always an immediate extension of the higher fraction. (It's not 1,7,56 -- it is 1,11,52). A "double double" is really a pair of double precision numbers, both with sign and exponent fields. If the first number has maximum exponent (so, it is infinity or a NaN), the second number is not significant; otherwise, the sum of the two numbers (taken as exact numbers, no rounding, no truncation, etc.) is the represented number. The first number should be that, rounded to double precision. So the second double does "add fraction bits" somewhat like this, but there is an implicit leading 1, for normal numbers, and there can be a gap between the two halves, too (like in 0x1p0 + 0x1p-100). Segher
New French PO file for 'gcc' (version 10.1-b20200322)
Hello, gentle maintainer. This is a message from the Translation Project robot. A revised PO file for textual domain 'gcc' has been submitted by the French team of translators. The file is available at: https://translationproject.org/latest/gcc/fr.po (This file, 'gcc-10.1-b20200322.fr.po', has just now been sent to you in a separate email.) All other PO files for your package are available in: https://translationproject.org/latest/gcc/ Please consider including all of these in your next release, whether official or a pretest. Whenever you have a new distribution with a new version number ready, containing a newer POT file, please send the URL of that distribution tarball to the address below. The tarball may be just a pretest or a snapshot, it does not even have to compile. It is just used by the translators when they need some extra translation context. The following HTML page has been updated: https://translationproject.org/domain/gcc.html If any question arises, please contact the translation coordinator. Thank you for all your work, The Translation Project robot, in the name of your translation coordinator.
Re: [PATCH] c++, middle-end, rs6000: Fix C++17 ABI incompatibilities during class layout [PR94707]
On Sat, Apr 25, 2020 at 6:03 AM Jakub Jelinek wrote: > > Hi! > > As reported by Iain and David, powerpc-darwin and powerpc-aix* have C++14 > vs. C++17 ABI incompatibilities which are not fixed by mere adding of > cxx17_empty_base_field_p calls. Unlike the issues that were seen on other > targets where the artificial empty base field affected function argument > passing or returning of values, on these two targets the difference is > during class layout, not afterwards (e.g. > struct empty_base {}; > struct S : public empty_base { unsigned long long l[2]; }; > will have different __alignof__ (S) between C++14 and C++17 (or possibly > with double instead of unsigned long long too)). > > The aim of the calls.c (cxx17_empty_base_field_p) was not to match random > artificial fields with zero size, because they could be created by something > else for some other reason, thus the DECL_SIZE is bitsize_zero but TYPE_SIZE > is non-zero check. Unfortunately, during the class layout, the empty base > fields have a different type, one which has zero size, so the predicate only > works after the class is laid out completely. > > This patch adds a langhook, which will return true for those cases. It > shouldn't be problematic with LTO, because lto1 should see only > structures/classes that are already laid out, or if it does some structure > layout, it won't be something that has C++17 empty base artificial fields. > > Tested with cross to powerpc-darwin12 on a simple testcase given from Iain, > but otherwise untested. > Iain/David, could you please test this on your targets? > Ok for trunk? The patch fixes the AIX failures. The rs6000 part is okay. Thanks for tracking down and fixing all of this fallout. Thanks, David > > 2020-04-25 Jakub Jelinek > > PR target/94707 > * langhooks.h (struct lang_hooks_for_decls): Add > cxx17_empty_base_field_p member. > * langhooks-def.h (LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_P): Define. > (LANG_HOOKS_DECLS): Use it. > * calls.c (cxx17_empty_base_field_p): Use > langhooks.decls.cxx17_empty_base_field_p. > * config/rs6000/rs6000.c (rs6000_special_round_type_align, > darwin_rs6000_special_round_type_align): Skip cxx17_empty_base_field_p > fields. > cp/ > * cp-objcp-common.h (cp_cxx17_empty_base_field_p): Declare. > (LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_P): Redefine. > * class.c (cp_cxx17_empty_base_field_p): New function. > > --- gcc/langhooks.h.jj 2020-03-17 13:50:52.262943386 +0100 > +++ gcc/langhooks.h 2020-04-25 11:06:11.921931710 +0200 > @@ -226,6 +226,9 @@ struct lang_hooks_for_decls >/* True if this decl may be called via a sibcall. */ >bool (*ok_for_sibcall) (const_tree); > > + /* True if this FIELD_DECL is C++17 empty base field. */ > + bool (*cxx17_empty_base_field_p) (const_tree); > + >/* Return a tree for the actual data of an array descriptor - or NULL_TREE > if original tree is not an array descriptor. If the second argument > is true, only the TREE_TYPE is returned without generating a new tree. > */ > --- gcc/langhooks-def.h.jj 2020-01-12 11:54:36.670409531 +0100 > +++ gcc/langhooks-def.h 2020-04-25 11:06:03.300061347 +0200 > @@ -241,6 +241,7 @@ extern tree lhd_unit_size_without_reusab > #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl > #define LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS NULL > #define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall > +#define LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_Phook_bool_const_tree_false > #define LANG_HOOKS_OMP_ARRAY_DATA hook_tree_tree_bool_null > #define LANG_HOOKS_OMP_IS_ALLOCATABLE_OR_PTR hook_bool_const_tree_false > #define LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT hook_tree_tree_bool_null > @@ -269,6 +270,7 @@ extern tree lhd_unit_size_without_reusab >LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \ >LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS, \ >LANG_HOOKS_DECL_OK_FOR_SIBCALL, \ > + LANG_HOOKS_CXX17_EMPTY_BASE_FIELD_P, \ >LANG_HOOKS_OMP_ARRAY_DATA, \ >LANG_HOOKS_OMP_IS_ALLOCATABLE_OR_PTR, \ >LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT, \ > --- gcc/calls.c.jj 2020-04-22 16:44:30.765946555 +0200 > +++ gcc/calls.c 2020-04-25 11:14:45.038217088 +0200 > @@ -6275,8 +6275,9 @@ cxx17_empty_base_field_p (const_tree fie > && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)) > && DECL_SIZE (field) > && integer_zerop (DECL_SIZE (field)) > - && TYPE_SIZE (TREE_TYPE (field)) > - && !integer_zerop (TYPE_SIZE (TREE_TYPE (field; > + && ((TYPE_SIZE (TREE_TYPE (field)) > + && !integer_zerop (TYPE_SIZE (TREE_TYPE (field > + || lang_hooks.decls.cxx17_empty_base_field_p (field))); > } > > /* Tell the garbage collector about GTY markers in this source file. */ > --- gcc/config/rs6000/rs6000.c.jj 2020-04-22 16:43:14.913087731 +0200 > +++ gcc/config/rs6000/rs6000.c
Re: [pushed] c++: implicit operator== with previous decl [PR94583]
On Sat, Apr 25, 2020 at 12:17:18AM -0400, Jason Merrill via Gcc-patches wrote: > P2085 clarified that a defaulted comparison operator must be the first > declaration of the function. Rejecting that avoids the ICE trying to > compare the noexcept-specifications. > > Tested x86_64-pc-linux-gnu, applying to trunk. > > gcc/cp/ChangeLog > 2020-04-24 Jason Merrill > > PR c++/94583 > * decl.c (redeclaration_error_message): Reject defaulted comparison > operator that has been previously declared. > --- > gcc/cp/decl.c | 8 > gcc/testsuite/g++.dg/cpp2a/spaceship-synth6.C | 11 +++ > 2 files changed, 19 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/spaceship-synth6.C > > diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c > index c8c2f080763..31b5884ca3a 100644 > --- a/gcc/cp/decl.c > +++ b/gcc/cp/decl.c > @@ -2972,6 +2972,14 @@ redeclaration_error_message (tree newdecl, tree > olddecl) > } > } > > + /* [class.compare.default]: A definition of a comparison operator as > + defaulted that appears in a class shall be the first declaration of > + that function. */ > + special_function_kind sfk = special_function_p (olddecl); > + if (sfk == sfk_comparison && DECL_DEFAULTED_FN (newdecl)) > + return G_("comparison operator %q+D defaulted after " > + "its first declaration"); > + This one still ICEs: namespace std { struct strong_ordering { }; } struct Q { friend std::strong_ordering operator<=>(const Q&, const Q&) = default; }; bool operator==(const Q&, const Q&) noexcept; Either we need to reject redeclaring the implicit operator==, or teach get_defaulted_eh_spec how to handle its DEFERRED_NOEXCEPT, before build_comparison_op/~comp_info resolves it, because otherwise we couldn't check that the noexcept-specifications match. Thoughts? Marek