From 6039cb96d1014373470a27f02e24c2c5e821a06c Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 13 Jul 2020 13:52:03 -0700 Subject: [PATCH] core: add tree-node comments As we've moved to 64-bit systems, the padding information has become conditionally inaccurate. I also hit cases where invalid tree codes did not get flagged as invalid. gcc/ * tree-core.h (tree_decl_with_vis, tree_function_decl): Note additional padding on 64-bits * tree.c (cache_integer_cst): Note why no caching of enum literals. (get_tree_code_name): Robustify error case. --- gcc/tree-core.h | 2 ++ gcc/tree.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/tree-core.h b/gcc/tree-core.h index 8c5a2e3c404..ba7f9ceb205 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1826,6 +1826,7 @@ struct GTY(()) tree_decl_with_vis { /* Belong to FUNCTION_DECL exclusively. */ unsigned regdecl_flag : 1; /* 14 unused bits. */ + /* 32 more unused on 64 bit HW. */ }; struct GTY(()) tree_var_decl { @@ -1901,6 +1902,7 @@ struct GTY(()) tree_function_decl { unsigned replaceable_operator : 1; /* 11 bits left for future expansion. */ + /* 32 bits on 64-bit HW. */ }; struct GTY(()) tree_translation_unit_decl { diff --git a/gcc/tree.c b/gcc/tree.c index 3d9968fd7a0..9102f8d4e54 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1771,6 +1771,8 @@ cache_integer_cst (tree t) break; case ENUMERAL_TYPE: + /* The slot used by TYPE_CACHED_VALUES is used for the enum + members. */ break; default: @@ -13254,7 +13256,9 @@ get_tree_code_name (enum tree_code code) { const char *invalid = ""; - if (code >= MAX_TREE_CODES) + /* The tree_code enum promotes to signed, but we could be getting + invalid values, so force an unsigned comparison. */ + if (unsigned (code) >= MAX_TREE_CODES) { if (code == 0xa5a5) return "ggc_freed"; -- 2.30.2