public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-73] c++: uses_template_parms cleanups
@ 2022-05-02 16:25 Marek Polacek
  0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2022-05-02 16:25 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:05cd2d3f588e2ecc0fd40c08d938fd016064b04d

commit r13-73-g05cd2d3f588e2ecc0fd40c08d938fd016064b04d
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Apr 27 18:36:29 2022 -0400

    c++: uses_template_parms cleanups
    
    gcc/cp/ChangeLog:
    
            * cp-tree.h (uses_template_parms): Adjust declaration.
            * pt.cc (uses_template_parms): Return bool.  Use a RAII sentinel.

Diff:
---
 gcc/cp/cp-tree.h |  2 +-
 gcc/cp/pt.cc     | 33 ++++++++++++++-------------------
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 72177999968..6de29c0571c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -7312,7 +7312,7 @@ extern tree lookup_template_class		(tree, tree, tree, tree,
 						 int, tsubst_flags_t);
 extern tree lookup_template_function		(tree, tree);
 extern tree lookup_template_variable		(tree, tree);
-extern int uses_template_parms			(tree);
+extern bool uses_template_parms			(tree);
 extern bool uses_template_parms_level		(tree, int);
 extern bool in_template_function		(void);
 extern bool need_generic_capture		(void);
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index e6006540e7a..23fbd8245d4 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -10884,35 +10884,30 @@ find_template_parameters (tree t, tree ctx_parms)
 
 /* Returns true if T depends on any template parameter.  */
 
-int
+bool
 uses_template_parms (tree t)
 {
-  if (t == NULL_TREE)
+  if (t == NULL_TREE || t == error_mark_node)
     return false;
 
-  bool dependent_p;
-  int saved_processing_template_decl;
+  /* Namespaces can't depend on any template parameters.  */
+  if (TREE_CODE (t) == NAMESPACE_DECL)
+    return false;
+
+  processing_template_decl_sentinel ptds (/*reset*/false);
+  ++processing_template_decl;
 
-  saved_processing_template_decl = processing_template_decl;
-  if (!saved_processing_template_decl)
-    processing_template_decl = 1;
   if (TYPE_P (t))
-    dependent_p = dependent_type_p (t);
+    return dependent_type_p (t);
   else if (TREE_CODE (t) == TREE_VEC)
-    dependent_p = any_dependent_template_arguments_p (t);
+    return any_dependent_template_arguments_p (t);
   else if (TREE_CODE (t) == TREE_LIST)
-    dependent_p = (uses_template_parms (TREE_VALUE (t))
-		   || uses_template_parms (TREE_CHAIN (t)));
+    return (uses_template_parms (TREE_VALUE (t))
+	    || uses_template_parms (TREE_CHAIN (t)));
   else if (TREE_CODE (t) == TYPE_DECL)
-    dependent_p = dependent_type_p (TREE_TYPE (t));
-  else if (t == error_mark_node || TREE_CODE (t) == NAMESPACE_DECL)
-    dependent_p = false;
+    return dependent_type_p (TREE_TYPE (t));
   else
-    dependent_p = instantiation_dependent_expression_p (t);
-
-  processing_template_decl = saved_processing_template_decl;
-
-  return dependent_p;
+    return instantiation_dependent_expression_p (t);
 }
 
 /* Returns true iff we're processing an incompletely instantiated function


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

only message in thread, other threads:[~2022-05-02 16:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 16:25 [gcc r13-73] c++: uses_template_parms cleanups Marek Polacek

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).