public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-4433] c++: small contracts fixes
Date: Thu,  1 Dec 2022 03:46:49 +0000 (GMT)	[thread overview]
Message-ID: <20221201034649.46E193858417@sourceware.org> (raw)

https://gcc.gnu.org/g:4304e09a1617bcf1c87f5bc96017ae5017379d75

commit r13-4433-g4304e09a1617bcf1c87f5bc96017ae5017379d75
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Nov 30 14:22:03 2022 -0500

    c++: small contracts fixes
    
    The first is an actual bug: remove_contract_attributes was only keeping one
    attribute.  The second just helps flow analysis in optimizers and static
    analyzers.
    
    gcc/cp/ChangeLog:
    
            * contracts.cc (remove_contract_attributes): Actually prepend
            to the list.
            * pt.cc (tsubst_contract): Only look for a postcondition if type is
            nonnull.

Diff:
---
 gcc/cp/contracts.cc | 2 +-
 gcc/cp/pt.cc        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index a9097016768..45f52b20392 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -869,7 +869,7 @@ remove_contract_attributes (tree fndecl)
   tree list = NULL_TREE;
   for (tree p = DECL_ATTRIBUTES (fndecl); p; p = TREE_CHAIN (p))
     if (!cxx_contract_attribute_p (p))
-      list = tree_cons (TREE_PURPOSE (p), TREE_VALUE (p), NULL_TREE);
+      list = tree_cons (TREE_PURPOSE (p), TREE_VALUE (p), list);
   DECL_ATTRIBUTES (fndecl) = nreverse (list);
 }
 
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 2d8e4fdd4b5..08de273a900 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -11561,7 +11561,7 @@ tsubst_contract (tree decl, tree t, tree args, tsubst_flags_t complain,
   tree r = copy_node (t);
 
   /* Rebuild the result variable.  */
-  if (POSTCONDITION_P (t) && POSTCONDITION_IDENTIFIER (t))
+  if (type && POSTCONDITION_P (t) && POSTCONDITION_IDENTIFIER (t))
     {
       tree oldvar = POSTCONDITION_IDENTIFIER (t);

                 reply	other threads:[~2022-12-01  3:46 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=20221201034649.46E193858417@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-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).