From: Jason Merrill Date: Fri, 21 Oct 2022 14:35:26 +0000 (-0400) Subject: c++: minor tweaks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=598a58d5539990b56c9a6c73ae1d0ed3445b5498;p=thirdparty%2Fgcc.git c++: minor tweaks gcc/cp/ChangeLog: * cp-tree.h (struct saved_scope): Move non-bitfield out from between bitfields. (DECL_CDTOR_NEEDS_LABLED_EXIT_P): Remove. * contracts.cc: Add FIXMEs. * pt.cc (register_specialization): Revert reformatting. --- diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc index 0bc8305570d3..11fd93362f3a 100644 --- a/gcc/cp/contracts.cc +++ b/gcc/cp/contracts.cc @@ -41,7 +41,7 @@ along with GCC; see the file COPYING3. If not see "v > 0", // comment, "default", // assertion_level, "default", // assertion_role, - CCS_MAYBE, // continuation_mode + MAYBE_CONTINUE, // continuation_mode ); } @@ -50,9 +50,16 @@ along with GCC; see the file COPYING3. If not see if the contract should not continue on violation. This prevents requiring including and simplifies building the call. + FIXME the overhead would be lower if we write out the contract_violation + object statically and pass it directly to the handler. Though the current + way is more tolerant of layout changes, so maybe leave it alone until the + feature is more mature. + Assumed contracts have a similar transformation that results the body of the if being __builtin_unreachable (); + FIXME use build_assume_call. + Parsing of pre and post contract conditions need to be deferred when the contracts are attached to a member function. The postcondition identifier cannot be used before the deduced return type of an auto function is used, @@ -135,7 +142,11 @@ along with GCC; see the file COPYING3. If not see for each return, or a goto epilogue would need generated similarly to cdtors. For this initial implementation, generating function calls and letting later optimizations decide whether to inline and duplicate the actual - checks or whether to collapse the shared epilogue was chosen. */ + checks or whether to collapse the shared epilogue was chosen. + + FIXME the compiler already handles sharing cleanup code on multiple exit + paths properly, this outlining isn't necessary if we represent the + postcondition as a cleanup (like I already did for dtors). */ #include "config.h" #include "system.h" diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f011231acb33..28e358a78d61 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1944,12 +1944,11 @@ struct GTY(()) saved_scope { int x_processing_template_decl; int x_processing_specialization; int x_processing_constraint; + int x_processing_contract_condition; int suppress_location_wrappers; BOOL_BITFIELD x_processing_explicit_instantiation : 1; BOOL_BITFIELD need_pop_function_context : 1; - int x_processing_contract_condition; - /* Nonzero if we are parsing the discarded statement of a constexpr if-statement. */ BOOL_BITFIELD discarded_stmt : 1; @@ -3250,14 +3249,6 @@ struct GTY(()) lang_decl { (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (NODE) \ || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (NODE)) -/* Nonzero if NODE (a FUNCTION_DECL) is a ctor or dtor that needs the cdtor - label and associated goto built. */ -#define DECL_CDTOR_NEEDS_LABLED_EXIT_P(NODE) \ - (DECL_DESTRUCTOR_P (NODE) \ - || (DECL_CONSTRUCTOR_P (NODE) \ - && (targetm.cxx.cdtor_returns_this () \ - || contract_any_active_p (DECL_CONTRACTS (NODE))))) - /* Nonzero if NODE (a _DECL) is a cloned constructor or destructor. */ #define DECL_CLONED_FUNCTION_P(NODE) \ diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 35da6da7a057..e1503ef8372b 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -1545,7 +1545,8 @@ register_specialization (tree spec, tree tmpl, tree args, bool is_friend, { if (DECL_TEMPLATE_INSTANTIATION (fn)) { - if (DECL_ODR_USED (fn) || DECL_EXPLICIT_INSTANTIATION (fn)) + if (DECL_ODR_USED (fn) + || DECL_EXPLICIT_INSTANTIATION (fn)) { error ("specialization of %qD after instantiation", fn);