[PATCH PR/82546] tree node size
authorNathan Sidwell <nathan@acm.org>
Tue, 17 Oct 2017 14:49:05 +0000 (14:49 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 17 Oct 2017 14:49:05 +0000 (14:49 +0000)
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00899.html
PR middle-end/82546
gcc/
* tree.c (tree_code_size): Reformat.  Punt to lang hook for unknown
TYPE nodes.
gcc/cp/
* cp-objcp-common.c (cp_tree_size): Reformat.  Adjust returns size
of TYPE nodes.
gcc/objc/
* objc-act.c (objc_common_tree_size): Return size of TYPE nodes.

From-SVN: r253817

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.c
gcc/objc/ChangeLog
gcc/objc/objc-act.c
gcc/tree.c

index b53ae8b3240079123ddee3dd26ed028bc294bc40..02d8e313d287173f972edf8a118ba6ec13a33df7 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-17  Nathan Sidwell  <nathan@acm.org>
+
+       PR middle-end/82546
+       * tree.c (tree_code_size): Reformat.  Punt to lang hook for unknown
+       TYPE nodes.
+
 2017-10-17  Qing Zhao <qing.zhao@oracle.com>
            Wilco Dijkstra <wilco.dijkstra@arm.com>
 
index 2b6e3b68b3c60876e8b1bc228623f590a36cc121..621efed82acbd6df188f2a67b8c33ac652580cac 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-17  Nathan Sidwell  <nathan@acm.org>
+
+       PR middle-end/82546
+       * cp-objcp-common.c (cp_tree_size): Reformat.  Adjust returns size
+       of TYPE nodes.
+
 2017-10-13  Jason Merrill  <jason@redhat.com>
 
        PR c++/82357 - bit-field in template
index f251b05775b2dc06864e29b2f906b65bf51cf009..e051d66b67b837b41b83af772006d1e5a25ae83e 100644 (file)
@@ -61,43 +61,34 @@ cxx_warn_unused_global_decl (const_tree decl)
 size_t
 cp_tree_size (enum tree_code code)
 {
+  gcc_checking_assert (code >= NUM_TREE_CODES);
   switch (code)
     {
-    case PTRMEM_CST:           return sizeof (struct ptrmem_cst);
-    case BASELINK:             return sizeof (struct tree_baselink);
+    case PTRMEM_CST:           return sizeof (ptrmem_cst);
+    case BASELINK:             return sizeof (tree_baselink);
     case TEMPLATE_PARM_INDEX:  return sizeof (template_parm_index);
-    case DEFAULT_ARG:          return sizeof (struct tree_default_arg);
-    case DEFERRED_NOEXCEPT:    return sizeof (struct tree_deferred_noexcept);
-    case OVERLOAD:             return sizeof (struct tree_overload);
-    case STATIC_ASSERT:         return sizeof (struct tree_static_assert);
+    case DEFAULT_ARG:          return sizeof (tree_default_arg);
+    case DEFERRED_NOEXCEPT:    return sizeof (tree_deferred_noexcept);
+    case OVERLOAD:             return sizeof (tree_overload);
+    case STATIC_ASSERT:         return sizeof (tree_static_assert);
     case TYPE_ARGUMENT_PACK:
-    case TYPE_PACK_EXPANSION:
-      return sizeof (struct tree_common);
-
+    case TYPE_PACK_EXPANSION:  return sizeof (tree_type_non_common);
     case NONTYPE_ARGUMENT_PACK:
-    case EXPR_PACK_EXPANSION:
-      return sizeof (struct tree_exp);
-
-    case ARGUMENT_PACK_SELECT:
-      return sizeof (struct tree_argument_pack_select);
-
-    case TRAIT_EXPR:
-      return sizeof (struct tree_trait_expr);
-
-    case LAMBDA_EXPR:           return sizeof (struct tree_lambda_expr);
-
-    case TEMPLATE_INFO:         return sizeof (struct tree_template_info);
-
-    case CONSTRAINT_INFO:       return sizeof (struct tree_constraint_info);
-
-    case USERDEF_LITERAL:      return sizeof (struct tree_userdef_literal);
-
-    case TEMPLATE_DECL:                return sizeof (struct tree_template_decl);
-
+    case EXPR_PACK_EXPANSION:  return sizeof (tree_exp);
+    case ARGUMENT_PACK_SELECT: return sizeof (tree_argument_pack_select);
+    case TRAIT_EXPR:           return sizeof (tree_trait_expr);
+    case LAMBDA_EXPR:           return sizeof (tree_lambda_expr);
+    case TEMPLATE_INFO:         return sizeof (tree_template_info);
+    case CONSTRAINT_INFO:       return sizeof (tree_constraint_info);
+    case USERDEF_LITERAL:      return sizeof (tree_userdef_literal);
+    case TEMPLATE_DECL:                return sizeof (tree_template_decl);
     default:
-      if (TREE_CODE_CLASS (code) == tcc_declaration)
-       return sizeof (struct tree_decl_non_common);
-      gcc_unreachable ();
+      switch (TREE_CODE_CLASS (code))
+       {
+       case tcc_declaration:   return sizeof (tree_decl_non_common);
+       case tcc_type:          return sizeof (tree_type_non_common);
+       default: gcc_unreachable ();
+       }
     }
   /* NOTREACHED */
 }
index 20b0fe44b29bb1edbaed05664eed4167172a9f38..a387814e9adc561dd387e5e7cfa885a8189f2590 100644 (file)
@@ -1,3 +1,7 @@
+2017-10-17  Nathan Sidwell  <nathan@acm.org>
+
+       * objc-act.c (objc_common_tree_size): Return size of TYPE nodes.
+
 2017-10-10  Richard Sandiford  <richard.sandiford@linaro.org>
 
        * objc-act.c (objc_decl_method_attributes): Use wi::to_wide when
index ce2adcc0dedb0537858e028390de5477cac99e6c..765192c82aaa548ec4fa8eb12cc92d36a0803589 100644 (file)
@@ -10118,11 +10118,14 @@ objc_common_tree_size (enum tree_code code)
     case CLASS_METHOD_DECL:
     case INSTANCE_METHOD_DECL:
     case KEYWORD_DECL:
-    case PROPERTY_DECL:
-      return sizeof (struct tree_decl_non_common);
+    case PROPERTY_DECL:                        return sizeof (tree_decl_non_common);
+    case CLASS_INTERFACE_TYPE:
+    case CLASS_IMPLEMENTATION_TYPE:
+    case CATEGORY_INTERFACE_TYPE:
+    case CATEGORY_IMPLEMENTATION_TYPE:
+    case PROTOCOL_INTERFACE_TYPE:      return sizeof (tree_type_non_common);
     default:
       gcc_unreachable ();
-  
     }
 }
 
index 5662f28c4692bf81d7e6c34713f2c3d92b4a9abe..cd77f08a331944ee5548572f2e01f799a4daff62 100644 (file)
@@ -763,40 +763,53 @@ tree_code_size (enum tree_code code)
   switch (TREE_CODE_CLASS (code))
     {
     case tcc_declaration:  /* A decl node */
-      {
-       switch (code)
-         {
-         case FIELD_DECL:
-           return sizeof (struct tree_field_decl);
-         case PARM_DECL:
-           return sizeof (struct tree_parm_decl);
-         case VAR_DECL:
-           return sizeof (struct tree_var_decl);
-         case LABEL_DECL:
-           return sizeof (struct tree_label_decl);
-         case RESULT_DECL:
-           return sizeof (struct tree_result_decl);
-         case CONST_DECL:
-           return sizeof (struct tree_const_decl);
-         case TYPE_DECL:
-           return sizeof (struct tree_type_decl);
-         case FUNCTION_DECL:
-           return sizeof (struct tree_function_decl);
-         case DEBUG_EXPR_DECL:
-           return sizeof (struct tree_decl_with_rtl);
-         case TRANSLATION_UNIT_DECL:
-           return sizeof (struct tree_translation_unit_decl);
-         case NAMESPACE_DECL:
-         case IMPORTED_DECL:
-         case NAMELIST_DECL:
-           return sizeof (struct tree_decl_non_common);
-         default:
-           return lang_hooks.tree_size (code);
-         }
-      }
+      switch (code)
+       {
+       case FIELD_DECL:        return sizeof (tree_field_decl);
+       case PARM_DECL:         return sizeof (tree_parm_decl);
+       case VAR_DECL:          return sizeof (tree_var_decl);
+       case LABEL_DECL:        return sizeof (tree_label_decl);
+       case RESULT_DECL:       return sizeof (tree_result_decl);
+       case CONST_DECL:        return sizeof (tree_const_decl);
+       case TYPE_DECL:         return sizeof (tree_type_decl);
+       case FUNCTION_DECL:     return sizeof (tree_function_decl);
+       case DEBUG_EXPR_DECL:   return sizeof (tree_decl_with_rtl);
+       case TRANSLATION_UNIT_DECL: return sizeof (tree_translation_unit_decl);
+       case NAMESPACE_DECL:
+       case IMPORTED_DECL:
+       case NAMELIST_DECL:     return sizeof (tree_decl_non_common);
+       default:
+         gcc_checking_assert (code >= NUM_TREE_CODES);
+         return lang_hooks.tree_size (code);
+       }
 
     case tcc_type:  /* a type node */
-      return sizeof (struct tree_type_non_common);
+      switch (code)
+       {
+       case OFFSET_TYPE:
+       case ENUMERAL_TYPE:
+       case BOOLEAN_TYPE:
+       case INTEGER_TYPE:
+       case REAL_TYPE:
+       case POINTER_TYPE:
+       case REFERENCE_TYPE:
+       case NULLPTR_TYPE:
+       case FIXED_POINT_TYPE:
+       case COMPLEX_TYPE:
+       case VECTOR_TYPE:
+       case ARRAY_TYPE:
+       case RECORD_TYPE:
+       case UNION_TYPE:
+       case QUAL_UNION_TYPE:
+       case VOID_TYPE:
+       case POINTER_BOUNDS_TYPE:
+       case FUNCTION_TYPE:
+       case METHOD_TYPE:
+       case LANG_TYPE:         return sizeof (tree_type_non_common);
+       default:
+         gcc_checking_assert (code >= NUM_TREE_CODES);
+         return lang_hooks.tree_size (code);
+       }
 
     case tcc_reference:   /* a reference */
     case tcc_expression:  /* an expression */
@@ -810,14 +823,15 @@ tree_code_size (enum tree_code code)
     case tcc_constant:  /* a constant */
       switch (code)
        {
-       case VOID_CST:          return sizeof (struct tree_typed);
+       case VOID_CST:          return sizeof (tree_typed);
        case INTEGER_CST:       gcc_unreachable ();
-       case REAL_CST:          return sizeof (struct tree_real_cst);
-       case FIXED_CST:         return sizeof (struct tree_fixed_cst);
-       case COMPLEX_CST:       return sizeof (struct tree_complex);
-       case VECTOR_CST:        return sizeof (struct tree_vector);
+       case REAL_CST:          return sizeof (tree_real_cst);
+       case FIXED_CST:         return sizeof (tree_fixed_cst);
+       case COMPLEX_CST:       return sizeof (tree_complex);
+       case VECTOR_CST:        return sizeof (tree_vector);
        case STRING_CST:        gcc_unreachable ();
        default:
+         gcc_checking_assert (code >= NUM_TREE_CODES);
          return lang_hooks.tree_size (code);
        }
 
@@ -825,23 +839,24 @@ tree_code_size (enum tree_code code)
       switch (code)
        {
        case IDENTIFIER_NODE:   return lang_hooks.identifier_size;
-       case TREE_LIST:         return sizeof (struct tree_list);
+       case TREE_LIST:         return sizeof (tree_list);
 
        case ERROR_MARK:
-       case PLACEHOLDER_EXPR:  return sizeof (struct tree_common);
+       case PLACEHOLDER_EXPR:  return sizeof (tree_common);
 
-       case TREE_VEC:
+       case TREE_VEC:          gcc_unreachable ();
        case OMP_CLAUSE:        gcc_unreachable ();
 
-       case SSA_NAME:          return sizeof (struct tree_ssa_name);
+       case SSA_NAME:          return sizeof (tree_ssa_name);
 
-       case STATEMENT_LIST:    return sizeof (struct tree_statement_list);
+       case STATEMENT_LIST:    return sizeof (tree_statement_list);
        case BLOCK:             return sizeof (struct tree_block);
-       case CONSTRUCTOR:       return sizeof (struct tree_constructor);
-       case OPTIMIZATION_NODE: return sizeof (struct tree_optimization_option);
-       case TARGET_OPTION_NODE: return sizeof (struct tree_target_option);
+       case CONSTRUCTOR:       return sizeof (tree_constructor);
+       case OPTIMIZATION_NODE: return sizeof (tree_optimization_option);
+       case TARGET_OPTION_NODE: return sizeof (tree_target_option);
 
        default:
+         gcc_checking_assert (code >= NUM_TREE_CODES);
          return lang_hooks.tree_size (code);
        }