public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* c++: Don't add enums to class's decl_list
@ 2020-07-22 15:41 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-07-22 15:41 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 241 bytes --]

We don't need to add CONST_DECLs to a template decl's decl list.  Also 
made the code flow a bit clearer.

             gcc/cp/
             * class.c (maybe_add_class_template_decl_list): Don't add 
CONST_DECLs.

nathan

-- 
Nathan Sidwell

[-- Attachment #2: class.diff --]
[-- Type: text/x-patch, Size: 796 bytes --]

diff --git i/gcc/cp/class.c w/gcc/cp/class.c
index 803b33bf346..a3913f4ce0b 100644
--- i/gcc/cp/class.c
+++ w/gcc/cp/class.c
@@ -3049,11 +3049,14 @@ finish_struct_anon (tree t)
 void
 maybe_add_class_template_decl_list (tree type, tree t, int friend_p)
 {
-  /* Save some memory by not creating TREE_LIST if TYPE is not template.  */
-  if (CLASSTYPE_TEMPLATE_INFO (type))
-    CLASSTYPE_DECL_LIST (type)
-      = tree_cons (friend_p ? NULL_TREE : type,
-		   t, CLASSTYPE_DECL_LIST (type));
+  if (CLASSTYPE_TEMPLATE_INFO (type)
+      && TREE_CODE (t) != CONST_DECL)
+    {
+      tree purpose = friend_p ? NULL_TREE : type;
+
+      CLASSTYPE_DECL_LIST (type)
+	= tree_cons (purpose, t, CLASSTYPE_DECL_LIST (type));
+    }
 }
 
 /* This function is called from declare_virt_assop_and_dtor via

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

only message in thread, other threads:[~2020-07-22 15:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 15:41 c++: Don't add enums to class's decl_list Nathan Sidwell

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