aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2011-10-13 14:25:10 -0400
committerDiego Novillo <dnovillo@gcc.gnu.org>2011-10-13 14:25:10 -0400
commit385b73ab1dd53d3815d929792166e07cc37f969f (patch)
tree8afb69dc05087ed6a7ddcb5c82f4429de08c3999
parent1fb0b80148f60850b5e2595d5e125cb826eafd6c (diff)
downloadgcc-385b73ab1dd53d3815d929792166e07cc37f969f.zip
gcc-385b73ab1dd53d3815d929792166e07cc37f969f.tar.gz
gcc-385b73ab1dd53d3815d929792166e07cc37f969f.tar.bz2
class.c (sorted_fields_type_new): Factor out of ...
* class.c (sorted_fields_type_new): Factor out of ... (finish_struct_1): ... here. From-SVN: r179939
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/class.c20
2 files changed, 22 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e70f5c8..18c98bb 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2011-10-13 Diego Novillo <dnovillo@google.com>
+
+ * class.c (sorted_fields_type_new): Factor out of ...
+ (finish_struct_1): ... here.
+
2011-10-13 Jason Merrill <jason@redhat.com>
PR c++/50618
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 2df9177..6185054 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5663,6 +5663,22 @@ determine_key_method (tree type)
return;
}
+
+/* Allocate and return an instance of struct sorted_fields_type with
+ N fields. */
+
+static struct sorted_fields_type *
+sorted_fields_type_new (int n)
+{
+ struct sorted_fields_type *sft;
+ sft = ggc_alloc_sorted_fields_type (sizeof (struct sorted_fields_type)
+ + n * sizeof (tree));
+ sft->len = n;
+
+ return sft;
+}
+
+
/* Perform processing required when the definition of T (a class type)
is complete. */
@@ -5792,9 +5808,7 @@ finish_struct_1 (tree t)
n_fields = count_fields (TYPE_FIELDS (t));
if (n_fields > 7)
{
- struct sorted_fields_type *field_vec = ggc_alloc_sorted_fields_type
- (sizeof (struct sorted_fields_type) + n_fields * sizeof (tree));
- field_vec->len = n_fields;
+ struct sorted_fields_type *field_vec = sorted_fields_type_new (n_fields);
add_fields_to_record_type (TYPE_FIELDS (t), field_vec, 0);
qsort (field_vec->elts, n_fields, sizeof (tree),
field_decl_cmp);