public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: document comp_template_args's default args
@ 2022-05-27 18:07 Patrick Palka
  2022-05-29 19:55 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2022-05-27 18:07 UTC (permalink / raw)
  To: gcc-patches

In passing, use bool for its return type.

gcc/cp/ChangeLog:

	* cp-tree.h (comp_template_args): Change return type to bool.
	* pt.cc (comp_template_args): Document default arguments.
	Change return type to bool and adjust returns accordingly.
---
 gcc/cp/cp-tree.h |  2 +-
 gcc/cp/pt.cc     | 24 +++++++++++-------------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index d77fd1eb8a9..da8898155e0 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -7327,7 +7327,7 @@ extern tree get_template_info			(const_tree);
 extern int template_class_depth			(tree);
 extern int is_specialization_of			(tree, tree);
 extern bool is_specialization_of_friend		(tree, tree);
-extern int comp_template_args			(tree, tree, tree * = NULL,
+extern bool comp_template_args			(tree, tree, tree * = NULL,
 						 tree * = NULL, bool = false);
 extern int template_args_equal                  (tree, tree, bool = false);
 extern tree maybe_process_partial_specialization (tree);
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index ec168234325..b5064990857 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -9368,27 +9368,25 @@ template_args_equal (tree ot, tree nt, bool partial_order /* = false */)
     }
 }
 
-/* Returns 1 iff the OLDARGS and NEWARGS are in fact identical sets of
-   template arguments.  Returns 0 otherwise, and updates OLDARG_PTR and
+/* Returns true iff the OLDARGS and NEWARGS are in fact identical sets of
+   template arguments.  Returns false otherwise, and updates OLDARG_PTR and
    NEWARG_PTR with the offending arguments if they are non-NULL.  */
 
-int
+bool
 comp_template_args (tree oldargs, tree newargs,
-		    tree *oldarg_ptr, tree *newarg_ptr,
-		    bool partial_order)
+		    tree *oldarg_ptr /* = NULL */, tree *newarg_ptr /* = NULL */,
+		    bool partial_order /* = false */)
 {
-  int i;
-
   if (oldargs == newargs)
-    return 1;
+    return true;
 
   if (!oldargs || !newargs)
-    return 0;
+    return false;
 
   if (TREE_VEC_LENGTH (oldargs) != TREE_VEC_LENGTH (newargs))
-    return 0;
+    return false;
 
-  for (i = 0; i < TREE_VEC_LENGTH (oldargs); ++i)
+  for (int i = 0; i < TREE_VEC_LENGTH (oldargs); ++i)
     {
       tree nt = TREE_VEC_ELT (newargs, i);
       tree ot = TREE_VEC_ELT (oldargs, i);
@@ -9399,10 +9397,10 @@ comp_template_args (tree oldargs, tree newargs,
 	    *oldarg_ptr = ot;
 	  if (newarg_ptr != NULL)
 	    *newarg_ptr = nt;
-	  return 0;
+	  return false;
 	}
     }
-  return 1;
+  return true;
 }
 
 inline bool
-- 
2.36.1.195.g8ddf593a25


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] c++: document comp_template_args's default args
  2022-05-27 18:07 [PATCH] c++: document comp_template_args's default args Patrick Palka
@ 2022-05-29 19:55 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2022-05-29 19:55 UTC (permalink / raw)
  To: Patrick Palka, gcc-patches

On 5/27/22 14:07, Patrick Palka wrote:
> In passing, use bool for its return type.

OK.

> gcc/cp/ChangeLog:
> 
> 	* cp-tree.h (comp_template_args): Change return type to bool.
> 	* pt.cc (comp_template_args): Document default arguments.
> 	Change return type to bool and adjust returns accordingly.
> ---
>   gcc/cp/cp-tree.h |  2 +-
>   gcc/cp/pt.cc     | 24 +++++++++++-------------
>   2 files changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
> index d77fd1eb8a9..da8898155e0 100644
> --- a/gcc/cp/cp-tree.h
> +++ b/gcc/cp/cp-tree.h
> @@ -7327,7 +7327,7 @@ extern tree get_template_info			(const_tree);
>   extern int template_class_depth			(tree);
>   extern int is_specialization_of			(tree, tree);
>   extern bool is_specialization_of_friend		(tree, tree);
> -extern int comp_template_args			(tree, tree, tree * = NULL,
> +extern bool comp_template_args			(tree, tree, tree * = NULL,
>   						 tree * = NULL, bool = false);
>   extern int template_args_equal                  (tree, tree, bool = false);
>   extern tree maybe_process_partial_specialization (tree);
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index ec168234325..b5064990857 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -9368,27 +9368,25 @@ template_args_equal (tree ot, tree nt, bool partial_order /* = false */)
>       }
>   }
>   
> -/* Returns 1 iff the OLDARGS and NEWARGS are in fact identical sets of
> -   template arguments.  Returns 0 otherwise, and updates OLDARG_PTR and
> +/* Returns true iff the OLDARGS and NEWARGS are in fact identical sets of
> +   template arguments.  Returns false otherwise, and updates OLDARG_PTR and
>      NEWARG_PTR with the offending arguments if they are non-NULL.  */
>   
> -int
> +bool
>   comp_template_args (tree oldargs, tree newargs,
> -		    tree *oldarg_ptr, tree *newarg_ptr,
> -		    bool partial_order)
> +		    tree *oldarg_ptr /* = NULL */, tree *newarg_ptr /* = NULL */,
> +		    bool partial_order /* = false */)
>   {
> -  int i;
> -
>     if (oldargs == newargs)
> -    return 1;
> +    return true;
>   
>     if (!oldargs || !newargs)
> -    return 0;
> +    return false;
>   
>     if (TREE_VEC_LENGTH (oldargs) != TREE_VEC_LENGTH (newargs))
> -    return 0;
> +    return false;
>   
> -  for (i = 0; i < TREE_VEC_LENGTH (oldargs); ++i)
> +  for (int i = 0; i < TREE_VEC_LENGTH (oldargs); ++i)
>       {
>         tree nt = TREE_VEC_ELT (newargs, i);
>         tree ot = TREE_VEC_ELT (oldargs, i);
> @@ -9399,10 +9397,10 @@ comp_template_args (tree oldargs, tree newargs,
>   	    *oldarg_ptr = ot;
>   	  if (newarg_ptr != NULL)
>   	    *newarg_ptr = nt;
> -	  return 0;
> +	  return false;
>   	}
>       }
> -  return 1;
> +  return true;
>   }
>   
>   inline bool


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-29 19:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 18:07 [PATCH] c++: document comp_template_args's default args Patrick Palka
2022-05-29 19:55 ` 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).