public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc/devel/c++-contracts] c++: comment tweaks
Date: Tue,  1 Nov 2022 11:43:05 +0000 (GMT)	[thread overview]
Message-ID: <20221101114305.F1F463858017@sourceware.org> (raw)

https://gcc.gnu.org/g:3a3e900ba634451f95443077a890f70003ec1fc6

commit 3a3e900ba634451f95443077a890f70003ec1fc6
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Oct 25 15:55:20 2022 -0400

    c++: comment tweaks

Diff:
---
 gcc/cp/contracts.cc                        | 18 +++++++++++-------
 libstdc++-v3/include/experimental/contract |  2 +-
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index 0a1626d6b68..2fa7023f76b 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -1,5 +1,5 @@
 /* Definitions for C++ contract levels
-   Copyright (C) 2020 Free Software Foundation, Inc.
+   Copyright (C) 2020-2022 Free Software Foundation, Inc.
    Contributed by Jeff Chapman II (jchapman@lock3software.com)
 
 This file is part of GCC.
@@ -131,20 +131,24 @@ along with GCC; see the file COPYING3.  If not see
    With the idea being that multiple return statements could collapse the
    function epilogue after inlining the pre/post functions. clang is able
    to collapse common function epilogues, while gcc needs -O3 -Os combined.
-   We're already doing this "manually" for cdtors due to the way they're already
-   implemented, forcing DECL_CDTOR_NEEDS_LABLED_EXIT_P to be true when the
-   cdtor has active contracts.
 
    Directly laying the pre contracts down in the function body doesn't have
    many issues. The post contracts may need to be repeated multiple times, once
-   for each return, or a goto epilogue would need generated similarly to cdtors.
+   for each return, or a goto epilogue would need to be generated.
    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.
 
+   For cdtors a post contract is implemented using a CLEANUP_STMT.
+
    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).  */
+   paths properly, so this outlining seems unnecessary if we represent the
+   postcondition as a cleanup for all functions.
+
+   More helpful for optimization might be to make the contracts a wrapper
+   function (for non-variadic functions), that could be inlined into a
+   caller while preserving the call to the actual function?  Either that or
+   turn a never-continue post contract into an assume in the caller.  */
 
 #include "config.h"
 #include "system.h"
diff --git a/libstdc++-v3/include/experimental/contract b/libstdc++-v3/include/experimental/contract
index a52c2a485cf..7a5f743665b 100644
--- a/libstdc++-v3/include/experimental/contract
+++ b/libstdc++-v3/include/experimental/contract
@@ -1,6 +1,6 @@
 // Contracts support header for -*- C++ -*-
 
-// Copyright (C) 1995-2018 Free Software Foundation, Inc.
+// Copyright (C) 1995-2022 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //

                 reply	other threads:[~2022-11-01 11:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221101114305.F1F463858017@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).