public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-contracts] c++: trivial contracts adjustments
@ 2021-07-06 20:43 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-07-06 20:43 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:7e03bf10f445b669ff9fd2055c45a43188f056b3

commit 7e03bf10f445b669ff9fd2055c45a43188f056b3
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 30 17:01:13 2021 -0400

    c++: trivial contracts adjustments
    
    gcc/cp/ChangeLog:
    
            * contracts.h: Tweak comment.
            * contracts.cc: Tweak comment.
            * cp-gimplify.c (cp_genericize_r): Remove commented-out code.
            * decl.c (duplicate_decls): Fix formatting.
            * mangle.c (write_encoding): Update comment.
            * parser.c (cp_parser_conditional_expression): Expand comment.
    
    libstdc++-v3/ChangeLog:
    
            * src/c++17/contract.cc (__on_contract_violation): Fix formatting.

Diff:
---
 gcc/cp/contracts.h                 |  2 +-
 gcc/cp/contracts.cc                |  2 +-
 gcc/cp/cp-gimplify.c               |  2 --
 gcc/cp/decl.c                      | 39 ++++++++++++++++++++------------------
 gcc/cp/mangle.c                    |  5 +----
 gcc/cp/parser.c                    |  8 ++++++--
 libstdc++-v3/src/c++17/contract.cc | 14 +++++++-------
 7 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/gcc/cp/contracts.h b/gcc/cp/contracts.h
index 3ae0d01c8bf..cf1890510b8 100644
--- a/gcc/cp/contracts.h
+++ b/gcc/cp/contracts.h
@@ -1,5 +1,5 @@
 /* Definitions for C++ contract levels.  Implements functionality described in
-   the working draft version of contracts, P1290, P1332, and P1429.
+   the N4820 working draft version of contracts, P1290, P1332, and P1429.
    Copyright (C) 2020 Free Software Foundation, Inc.
    Contributed by Jeff Chapman II (jchapman@lock3software.com)
 
diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index 0e64dc08e99..4df25a104d2 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -1409,7 +1409,7 @@ build_contract_condition_function (tree fndecl, bool pre)
   tree *last = &arg_types;
 
   /* FIXME will later optimizations delete unused args to prevent extra arg
-   * passing? do we care? */
+     passing? do we care? */
   tree class_type = NULL_TREE;
   for (tree arg_type = TYPE_ARG_TYPES (TREE_TYPE (fn));
       arg_type && arg_type != void_list_node;
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 2c15b39b2ed..59bb34d723a 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -1200,8 +1200,6 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
       {
 	if (tree check = build_contract_check (stmt))
 	  {
-	//     verbatim ("MAKE CHECK");
-	//     debug_expression (check);
 	    /* Mark the current function as possibly throwing exceptions
 	       (through invocation of the contract violation handler).  */
 	    current_function_returns_abnormally = 1;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a622b13692c..e4ef6b37ac0 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1467,6 +1467,7 @@ duplicate_function_template_decls (tree newdecl, tree olddecl)
    grokdecl. Friend declarations are merged together before attributes are
    processed, which complicates the processing of contracts. In particular, we
    need to compare and possibly remap contracts in duplicate_decls.  */
+/* FIXME make this go away.  */
 
 static tree friend_attributes;
 
@@ -2931,26 +2932,28 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden)
 	      if (DECL_INITIAL (olddecl)
 		  && DECL_CONTRACTS (newdecl)
 		  && !DECL_CONTRACTS (olddecl))
-		    copy_contract_attributes (olddecl, newdecl);
-	      else {
-	      /* Temporarily undo the re-contexting of parameters so we
-		 can actually remap parameters.  The inliner won't replace
-		 parameters if we don't do this.  */
-	      tree args = DECL_ARGUMENTS (newdecl);
-	      for (tree p = args; p; p = DECL_CHAIN (p))
-		DECL_CONTEXT (p) = newdecl;
+		copy_contract_attributes (olddecl, newdecl);
+	      else
+		{
+		  /* Temporarily undo the re-contexting of parameters so we can
+		     actually remap parameters.  The inliner won't replace
+		     parameters if we don't do this.  */
+		  tree args = DECL_ARGUMENTS (newdecl);
+		  for (tree p = args; p; p = DECL_CHAIN (p))
+		    DECL_CONTEXT (p) = newdecl;
 
-	      /* Save new argument names for use in contracts parsing, unless
-		 we've already started parsing the body of olddecl (particular
-		 issues arise when newdecl is from a prior friend decl with no
-		 argument names, see modules/contracts-tpl-friend-1).  */
-	      if (tree contracts = DECL_CONTRACTS (olddecl))
-		remap_contracts (newdecl, olddecl, contracts, true);
+		  /* Save new argument names for use in contracts parsing,
+		     unless we've already started parsing the body of olddecl
+		     (particular issues arise when newdecl is from a prior
+		     friend decl with no argument names, see
+		     modules/contracts-tpl-friend-1).  */
+		  if (tree contracts = DECL_CONTRACTS (olddecl))
+		    remap_contracts (newdecl, olddecl, contracts, true);
 
-	      /* And reverse this operation again. */
-	      for (tree p = args; p; p = DECL_CHAIN (p))
-		DECL_CONTEXT (p) = olddecl;
-	      }
+		  /* And reverse this operation again. */
+		  for (tree p = args; p; p = DECL_CHAIN (p))
+		    DECL_CONTEXT (p) = olddecl;
+		}
 
 	      DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
 	    }
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 18d8107af55..586a13538f4 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -834,10 +834,7 @@ write_encoding (const tree decl)
 				d);
 
       /* If this is the pre/post function for a guarded function, append
-	 pre/post in the vendor specific portion of the mangling.
-
-	 TODO: this likely needs standardizing.
-	 TODO: do we need special handling in other tools like the demangler? */
+	 .pre/post, like something from create_virtual_clone.  */
       if (DECL_IS_PRE_FN_P (decl))
 	write_string (".pre");
       else if (DECL_IS_POST_FN_P (decl))
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 38ffe1f7d92..20e7d21aa40 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -16297,12 +16297,16 @@ cp_parser_conversion_declarator_opt (cp_parser* parser)
   return NULL;
 }
 
-/* Parse a conditional-expression.  */
+/* Parse a conditional-expression.
+
+   conditional-expression :
+	logical-or-expression
+	logical-or-expression ? expression : assignment-expression  */
 
 static cp_expr
 cp_parser_conditional_expression (cp_parser *parser)
 {
-  /* Parse the binary expressions (logical-or-expression).  */
+  /* Parse the binary expression (logical-or-expression).  */
   cp_expr expression = cp_parser_binary_expression (parser, false, false, false,
 						    PREC_NOT_OPERATOR, NULL);
   /* If the next token is a `?' then we're actually looking at
diff --git a/libstdc++-v3/src/c++17/contract.cc b/libstdc++-v3/src/c++17/contract.cc
index c13560e4341..56ee9c8e841 100644
--- a/libstdc++-v3/src/c++17/contract.cc
+++ b/libstdc++-v3/src/c++17/contract.cc
@@ -110,13 +110,13 @@ handle_contract_violation (const std::contract_violation &violation)
 // We take POD types here to make synthesis easier
 int
 __on_contract_violation (bool continue_,
-                         int line_number,
-                         const char *file_name,
-                         const char *function_name,
-                         const char *comment,
-                         const char *assertion_level,
-                         const char *assertion_role,
-                         int continuation_mode)
+			 int line_number,
+			 const char *file_name,
+			 const char *function_name,
+			 const char *comment,
+			 const char *assertion_level,
+			 const char *assertion_role,
+			 int continuation_mode)
 {
   using cvmc = std::contract_violation_continuation_mode;
   std::contract_violation violation (line_number,


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

only message in thread, other threads:[~2021-07-06 20:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 20:43 [gcc/devel/c++-contracts] c++: trivial contracts adjustments 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).