diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-10-28 08:11:35 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-10-28 08:13:17 -0700 |
commit | 7d5f38e49e59a09140473aa592133360428a1d83 (patch) | |
tree | 3d30f0a31d269069979b2b9ca29a93d98ed936cd | |
parent | 176b8b9679dfec881b7cf379f808cca3950b1e74 (diff) | |
download | gcc-7d5f38e49e59a09140473aa592133360428a1d83.zip gcc-7d5f38e49e59a09140473aa592133360428a1d83.tar.gz gcc-7d5f38e49e59a09140473aa592133360428a1d83.tar.bz2 |
c++: Refactor push_template_decl
Sadly I need to wander into push_template_decl again. But here's a
piece of RAII goodness first.
gcc/cp/
* pt.c (push_template_decl): Refactor for some RAII.
-rw-r--r-- | gcc/cp/pt.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3c0f254..0d2946f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5682,12 +5682,6 @@ template_parm_outer_level (tree t, void *data) tree push_template_decl (tree decl, bool is_friend) { - tree tmpl; - tree args; - tree info; - tree ctx; - bool is_primary; - bool is_partial; int new_template_p = 0; /* True if the template is a member template, in the sense of [temp.mem]. */ @@ -5697,19 +5691,20 @@ push_template_decl (tree decl, bool is_friend) return error_mark_node; /* See if this is a partial specialization. */ - is_partial = ((DECL_IMPLICIT_TYPEDEF_P (decl) - && TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE - && CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (decl))) - || (VAR_P (decl) - && DECL_LANG_SPECIFIC (decl) - && DECL_TEMPLATE_SPECIALIZATION (decl) - && TINFO_USED_TEMPLATE_ID (DECL_TEMPLATE_INFO (decl)))); + bool is_partial = ((DECL_IMPLICIT_TYPEDEF_P (decl) + && TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE + && CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (decl))) + || (VAR_P (decl) + && DECL_LANG_SPECIFIC (decl) + && DECL_TEMPLATE_SPECIALIZATION (decl) + && TINFO_USED_TEMPLATE_ID (DECL_TEMPLATE_INFO (decl)))); /* No surprising friend functions. */ gcc_checking_assert (is_friend || !(TREE_CODE (decl) == FUNCTION_DECL && DECL_UNIQUE_FRIEND_P (decl))); + tree ctx; if (is_friend) /* For a friend, we want the context of the friend, not the type of which it is a friend. */ @@ -5731,14 +5726,16 @@ push_template_decl (tree decl, bool is_friend) DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace); /* See if this is a primary template. */ + bool is_primary = false; if (is_friend && ctx && uses_template_parms_level (ctx, processing_template_decl)) /* A friend template that specifies a class context, i.e. template <typename T> friend void A<T>::f(); is not primary. */ - is_primary = false; + ; else if (TREE_CODE (decl) == TYPE_DECL && LAMBDA_TYPE_P (TREE_TYPE (decl))) - is_primary = false; + /* Lambdas are not primary. */ + ; else is_primary = template_parm_scope_p (); @@ -5871,8 +5868,9 @@ push_template_decl (tree decl, bool is_friend) if (is_partial) return process_partial_specialization (decl); - args = current_template_args (); + tree args = current_template_args (); + tree tmpl; if (!ctx || TREE_CODE (ctx) == FUNCTION_DECL || (CLASS_TYPE_P (ctx) && TYPE_BEING_DEFINED (ctx)) @@ -6077,7 +6075,7 @@ push_template_decl (tree decl, bool is_friend) if (DECL_TEMPLATE_INFO (tmpl)) args = add_outermost_template_args (DECL_TI_ARGS (tmpl), args); - info = build_template_info (tmpl, args); + tree info = build_template_info (tmpl, args); if (DECL_IMPLICIT_TYPEDEF_P (decl)) SET_TYPE_TEMPLATE_INFO (TREE_TYPE (tmpl), info); |