public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-contracts] c++: minor tweaks
@ 2022-10-25 17:50 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-10-25 17:50 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:598a58d5539990b56c9a6c73ae1d0ed3445b5498

commit 598a58d5539990b56c9a6c73ae1d0ed3445b5498
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Oct 21 10:35:26 2022 -0400

    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:
---
 gcc/cp/cp-tree.h    | 11 +----------
 gcc/cp/contracts.cc | 15 +++++++++++++--
 gcc/cp/pt.cc        |  3 ++-
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index f011231acb3..28e358a78d6 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/contracts.cc b/gcc/cp/contracts.cc
index 0bc8305570d..11fd93362f3 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 <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"
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 35da6da7a05..e1503ef8372 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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-25 17:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 17:50 [gcc/devel/c++-contracts] c++: minor tweaks Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).