aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-05-14 07:22:54 -0700
committerNathan Sidwell <nathan@acm.org>2020-05-14 07:22:54 -0700
commitddbaab134ca4603f7d4ac0d1646f40f9c13405ff (patch)
treec979a589bc9e1a3f2fd3f82b81f95c4f4a50d02c
parentea5a33d4536ce2af90255782bda0ada632952205 (diff)
downloadgcc-ddbaab134ca4603f7d4ac0d1646f40f9c13405ff.zip
gcc-ddbaab134ca4603f7d4ac0d1646f40f9c13405ff.tar.gz
gcc-ddbaab134ca4603f7d4ac0d1646f40f9c13405ff.tar.bz2
c++: Simplify tsubst_friend_function
tsubst_friend_function's control flow was a little complicated. This simplifies it, primarily by using more RAII. * pt.c (tsubst_friend_function): Simplify control flow.
-rw-r--r--gcc/cp/ChangeLog2
-rw-r--r--gcc/cp/pt.c28
2 files changed, 15 insertions, 15 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ab6130e..9dd04d2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,7 @@
2020-05-14 Nathan Sidwell <nathan@acm.org>
+ * pt.c (tsubst_friend_function): Simplify control flow.
+
* pt.c (lookup_template_class_1): Remove unnecessary else by
simply grabbing TYPE_NAME earlier.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 55f72e3..4517147 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10900,6 +10900,8 @@ tsubst_friend_function (tree decl, tree args)
}
new_friend = tsubst (decl, args, tf_warning_or_error, NULL_TREE);
+ if (new_friend == error_mark_node)
+ return error_mark_node;
/* The NEW_FRIEND will look like an instantiation, to the
compiler, but is not an instantiation from the point of view of
@@ -10911,11 +10913,9 @@ tsubst_friend_function (tree decl, tree args)
Then, in S<int>, template <class U> void f(int, U) is not an
instantiation of anything. */
- if (new_friend == error_mark_node)
- return error_mark_node;
DECL_USE_TEMPLATE (new_friend) = 0;
- if (TREE_CODE (decl) == TEMPLATE_DECL)
+ if (TREE_CODE (new_friend) == TEMPLATE_DECL)
{
DECL_USE_TEMPLATE (DECL_TEMPLATE_RESULT (new_friend)) = 0;
DECL_SAVED_TREE (DECL_TEMPLATE_RESULT (new_friend))
@@ -10942,29 +10942,27 @@ tsubst_friend_function (tree decl, tree args)
if (DECL_NAMESPACE_SCOPE_P (new_friend))
{
tree old_decl;
- tree new_friend_template_info;
- tree new_friend_result_template_info;
tree ns;
- int new_friend_is_defn;
/* We must save some information from NEW_FRIEND before calling
duplicate decls since that function will free NEW_FRIEND if
possible. */
- new_friend_template_info = DECL_TEMPLATE_INFO (new_friend);
- new_friend_is_defn =
- (DECL_INITIAL (DECL_TEMPLATE_RESULT
- (template_for_substitution (new_friend)))
- != NULL_TREE);
+ tree new_friend_template_info = DECL_TEMPLATE_INFO (new_friend);
+ tree new_friend_result_template_info = NULL_TREE;
+ bool new_friend_is_defn =
+ (DECL_INITIAL (DECL_TEMPLATE_RESULT
+ (template_for_substitution (new_friend)))
+ != NULL_TREE);
+ tree not_tmpl = new_friend;
+
if (TREE_CODE (new_friend) == TEMPLATE_DECL)
{
/* This declaration is a `primary' template. */
DECL_PRIMARY_TEMPLATE (new_friend) = new_friend;
- new_friend_result_template_info
- = DECL_TEMPLATE_INFO (DECL_TEMPLATE_RESULT (new_friend));
+ not_tmpl = DECL_TEMPLATE_RESULT (new_friend);
+ new_friend_result_template_info = DECL_TEMPLATE_INFO (not_tmpl);
}
- else
- new_friend_result_template_info = NULL_TREE;
/* Inside pushdecl_namespace_level, we will push into the
current namespace. However, the friend function should go