Skip to content

Commit 4f06ce1

Browse files
c++: share more trees representing enumerators
This came up in Reflection where an assert fails because we have two different trees for same enumerators. The reason is that in finish_enum_value_list we copy_node when converting the enumerators. It should be more efficient to share trees for identical enumerators. This fix was proposed by Jakub. gcc/cp/ChangeLog: * decl.cc (finish_enum_value_list): Use fold_convert instead of copy_node. Co-authored-by: Jakub Jelinek <jakub@redhat.com> Reviewed-by: Jason Merrill <jason@redhat.com>
1 parent 14f7cfd commit 4f06ce1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

gcc/cp/decl.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18958,13 +18958,9 @@ finish_enum_value_list (tree enumtype)
1895818958
value = perform_implicit_conversion (underlying_type,
1895918959
DECL_INITIAL (decl),
1896018960
tf_warning_or_error);
18961-
/* Do not clobber shared ints. */
18962-
if (value != error_mark_node)
18963-
{
18964-
value = copy_node (value);
18961+
/* Do not clobber shared ints. But do share identical enumerators. */
18962+
value = fold_convert (enumtype, value);
1896518963

18966-
TREE_TYPE (value) = enumtype;
18967-
}
1896818964
DECL_INITIAL (decl) = value;
1896918965
if (export_p)
1897018966
DECL_MODULE_EXPORT_P (decl) = true;

0 commit comments

Comments
 (0)