]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: minor tweaks
authorJason Merrill <jason@redhat.com>
Fri, 21 Oct 2022 14:35:26 +0000 (10:35 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 25 Oct 2022 17:50:00 +0000 (13:50 -0400)
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.

gcc/cp/contracts.cc
gcc/cp/cp-tree.h
gcc/cp/pt.cc

index 0bc8305570d358af784c8d2c8cdb1754150c19a7..11fd93362f3af9d9591640ee0fe76347126b71c3 100644 (file)
@@ -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 <contract> 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"
index f011231acb33999b2c46a1d5d0051636dadc5896..28e358a78d6164479a919784249baaf2c30b0f15 100644 (file)
@@ -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)           \
index 35da6da7a057a3df03fb852920320f4aa048cee8..e1503ef8372be27937cc0c3856abc6b5c2cf5628 100644 (file)
@@ -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);