diff mbox series

[C++] more pt.c simplifications

Message ID f5d3ff5f-0ebf-9e09-fe24-88ee45373b84@acm.org
State New
Headers show
Series [C++] more pt.c simplifications | expand

Commit Message

Nathan Sidwell May 14, 2020, 2:53 p.m. UTC
Pushed this bunch of simplifications to the template machinery.  As 
ever, discovered when implementing modules and figuring out how it worked.

inst-friend.diff
tsubst_friend_function's control flow was a little complicated.  This 
simplifies it, primarily by using more RAII.

lkp-class.diff
We were checking TYPE_NAME and then copying it if not null.  Just copy 
it, and then see if we got null.

push-tpl.diff
Push_template_decl_real's friend-pushing logic was confusing me.  This 
is more understandable.  Fix a latent type bug I disovered.


nathan
diff mbox series

Patch

2020-05-14  Nathan Sidwell  <nathan@acm.org>

	* pt.c (lookup_template_class_1): Remove unnecessary else by
	simply grabbing TYPE_NAME earlier.

diff --git i/gcc/cp/pt.c w/gcc/cp/pt.c
index 837644f8e6c..5ca659e9f28 100644
--- i/gcc/cp/pt.c
+++ w/gcc/cp/pt.c
@@ -9911,7 +9919,8 @@  lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
 
       /* If we called start_enum or pushtag above, this information
 	 will already be set up.  */
-      if (!TYPE_NAME (t))
+      type_decl = TYPE_NAME (t);
+      if (!type_decl)
 	{
 	  TYPE_CONTEXT (t) = FROB_CONTEXT (context);
 
@@ -9920,8 +9929,6 @@  lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
 	  DECL_SOURCE_LOCATION (type_decl)
 	    = DECL_SOURCE_LOCATION (TYPE_STUB_DECL (template_type));
 	}
-      else
-	type_decl = TYPE_NAME (t);
 
       if (CLASS_TYPE_P (template_type))
 	{