diff mbox series

c++: Don't add enums to class's decl_list

Message ID 25dc6bf7-9038-20fd-373c-15d60a8e495e@acm.org
State New
Headers show
Series c++: Don't add enums to class's decl_list | expand

Commit Message

Nathan Sidwell July 22, 2020, 3:41 p.m. UTC
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
diff mbox series

Patch

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