c-common.c (field_decl_cmp, [...]): Move to c/c-decl.c.
authorNathan Sidwell <nathan@acm.org>
Tue, 12 Sep 2017 14:25:17 +0000 (14:25 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 12 Sep 2017 14:25:17 +0000 (14:25 +0000)
c-family/
* c-common.c (field_decl_cmp, resort_data, resort_field_decl_cmp,
resort_sorted_fields): Move to c/c-decl.c.
* c-common.h (field_decl_cmp, resort_sorted_fields): Delete.
(struct sorted_fields_type): Move to c/c-lang.h.

c/
* c-decl.c (field_decl_cmp, resort_data, resort_field_decl_cmp,
resort_sorted_fields): Moved from c-family/c-common.c.
* c-lang.h (struct sorted_fields_type): Moved from c-family/c-common.h.

From-SVN: r252023

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/c/c-lang.h

index 3d959492d11762421b6106848d66ef9995ea1388..29037e5af8fcd465ad5ac711a60499c61d05aae9 100644 (file)
@@ -1,3 +1,10 @@
+2017-09-12  Nathan Sidwell  <nathan@acm.org>
+
+       * c-common.c (field_decl_cmp, resort_data, resort_field_decl_cmp,
+       resort_sorted_fields): Move to c/c-decl.c.
+       * c-common.h (field_decl_cmp, resort_sorted_fields): Delete.
+       (struct sorted_fields_type): Move to c/c-lang.h.
+
 2017-09-09  Jonathan Wakely  <jwakely@redhat.com>
 
        PR c++/81852
index af50cc729a2e4ed76d2867f31d2f67100b676d4b..b3ec3a0f7e6917b1f6cb9bf90d0edda82cb4ef5e 100644 (file)
@@ -309,7 +309,6 @@ static bool check_case_bounds (location_t, tree, tree, tree *, tree *,
 
 static void check_nonnull_arg (void *, tree, unsigned HOST_WIDE_INT);
 static bool nonnull_check_p (tree, unsigned HOST_WIDE_INT);
-static int resort_field_decl_cmp (const void *, const void *);
 
 /* Reserved words.  The third field is a mask: keywords are disabled
    if they match the mask.
@@ -5871,73 +5870,6 @@ check_builtin_function_arguments (location_t loc, vec<location_t> arg_loc,
     }
 }
 
-/* Function to help qsort sort FIELD_DECLs by name order.  */
-
-int
-field_decl_cmp (const void *x_p, const void *y_p)
-{
-  const tree *const x = (const tree *) x_p;
-  const tree *const y = (const tree *) y_p;
-
-  if (DECL_NAME (*x) == DECL_NAME (*y))
-    /* A nontype is "greater" than a type.  */
-    return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
-  if (DECL_NAME (*x) == NULL_TREE)
-    return -1;
-  if (DECL_NAME (*y) == NULL_TREE)
-    return 1;
-  if (DECL_NAME (*x) < DECL_NAME (*y))
-    return -1;
-  return 1;
-}
-
-static struct {
-  gt_pointer_operator new_value;
-  void *cookie;
-} resort_data;
-
-/* This routine compares two fields like field_decl_cmp but using the
-pointer operator in resort_data.  */
-
-static int
-resort_field_decl_cmp (const void *x_p, const void *y_p)
-{
-  const tree *const x = (const tree *) x_p;
-  const tree *const y = (const tree *) y_p;
-
-  if (DECL_NAME (*x) == DECL_NAME (*y))
-    /* A nontype is "greater" than a type.  */
-    return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
-  if (DECL_NAME (*x) == NULL_TREE)
-    return -1;
-  if (DECL_NAME (*y) == NULL_TREE)
-    return 1;
-  {
-    tree d1 = DECL_NAME (*x);
-    tree d2 = DECL_NAME (*y);
-    resort_data.new_value (&d1, resort_data.cookie);
-    resort_data.new_value (&d2, resort_data.cookie);
-    if (d1 < d2)
-      return -1;
-  }
-  return 1;
-}
-
-/* Resort DECL_SORTED_FIELDS because pointers have been reordered.  */
-
-void
-resort_sorted_fields (void *obj,
-                     void * ARG_UNUSED (orig_obj),
-                     gt_pointer_operator new_value,
-                     void *cookie)
-{
-  struct sorted_fields_type *sf = (struct sorted_fields_type *) obj;
-  resort_data.new_value = new_value;
-  resort_data.cookie = cookie;
-  qsort (&sf->elts[0], sf->len, sizeof (tree),
-        resort_field_decl_cmp);
-}
-
 /* Subroutine of c_parse_error.
    Return the result of concatenating LHS and RHS. RHS is really
    a string literal, its first character is indicated by RHS_START and
index 8e367680600332fd9b4750221d3286468677d269..0de549d2412393c27bbfdf7678db05493279746d 100644 (file)
@@ -493,13 +493,6 @@ extern const unsigned int num_c_common_reswords;
 
 extern GTY(()) tree c_global_trees[CTI_MAX];
 
-/* In a RECORD_TYPE, a sorted array of the fields of the type, not a
-   tree for size reasons.  */
-struct GTY(()) sorted_fields_type {
-  int len;
-  tree GTY((length ("%h.len"))) elts[1];
-};
-
 /* Mark which labels are explicitly declared.
    These may be shadowed, and may be referenced from nested functions.  */
 #define C_DECLARED_LABEL_FLAG(label) TREE_LANG_FLAG_1 (label)
@@ -597,9 +590,6 @@ extern tree build_array_notation_expr (location_t, tree, tree, enum tree_code,
 extern tree build_array_notation_ref (location_t, tree, tree, tree, tree, tree);
 extern tree build_indirect_ref (location_t, tree, ref_operator);
 
-extern int field_decl_cmp (const void *, const void *);
-extern void resort_sorted_fields (void *, void *, gt_pointer_operator,
-                                 void *);
 extern bool has_c_linkage (const_tree decl);
 extern bool c_decl_implicit (const_tree);
 \f
index 2d25c4816c650c39d14ce11447ceefec275b6232..d55b5ac42e48085fd7fdc58975e9ea4f29f3f4fb 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-12  Nathan Sidwell  <nathan@acm.org>
+
+       * c-decl.c (field_decl_cmp, resort_data, resort_field_decl_cmp,
+       resort_sorted_fields): Moved from c-family/c-common.c.
+       * c-lang.h (struct sorted_fields_type): Moved from c-family/c-common.h.
+
 2017-09-01  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/82071
index d526f0e88e4e20a6000f93944e8a9e10732d99d5..712149823290a32bab163fb5de8642b053371f16 100644 (file)
@@ -7840,6 +7840,26 @@ warn_cxx_compat_finish_struct (tree fieldlist, enum tree_code code,
     b->in_struct = 0;
 }
 
+/* Function to help qsort sort FIELD_DECLs by name order.  */
+
+static int
+field_decl_cmp (const void *x_p, const void *y_p)
+{
+  const tree *const x = (const tree *) x_p;
+  const tree *const y = (const tree *) y_p;
+
+  if (DECL_NAME (*x) == DECL_NAME (*y))
+    /* A nontype is "greater" than a type.  */
+    return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
+  if (DECL_NAME (*x) == NULL_TREE)
+    return -1;
+  if (DECL_NAME (*y) == NULL_TREE)
+    return 1;
+  if (DECL_NAME (*x) < DECL_NAME (*y))
+    return -1;
+  return 1;
+}
+
 /* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
    LOC is the location of the RECORD_TYPE or UNION_TYPE's definition.
    FIELDLIST is a chain of FIELD_DECL nodes for the fields.
@@ -8165,6 +8185,53 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
   return t;
 }
 
+static struct {
+  gt_pointer_operator new_value;
+  void *cookie;
+} resort_data;
+
+/* This routine compares two fields like field_decl_cmp but using the
+pointer operator in resort_data.  */
+
+static int
+resort_field_decl_cmp (const void *x_p, const void *y_p)
+{
+  const tree *const x = (const tree *) x_p;
+  const tree *const y = (const tree *) y_p;
+
+  if (DECL_NAME (*x) == DECL_NAME (*y))
+    /* A nontype is "greater" than a type.  */
+    return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
+  if (DECL_NAME (*x) == NULL_TREE)
+    return -1;
+  if (DECL_NAME (*y) == NULL_TREE)
+    return 1;
+  {
+    tree d1 = DECL_NAME (*x);
+    tree d2 = DECL_NAME (*y);
+    resort_data.new_value (&d1, resort_data.cookie);
+    resort_data.new_value (&d2, resort_data.cookie);
+    if (d1 < d2)
+      return -1;
+  }
+  return 1;
+}
+
+/* Resort DECL_SORTED_FIELDS because pointers have been reordered.  */
+
+void
+resort_sorted_fields (void *obj,
+                     void * ARG_UNUSED (orig_obj),
+                     gt_pointer_operator new_value,
+                     void *cookie)
+{
+  struct sorted_fields_type *sf = (struct sorted_fields_type *) obj;
+  resort_data.new_value = new_value;
+  resort_data.cookie = cookie;
+  qsort (&sf->elts[0], sf->len, sizeof (tree),
+        resort_field_decl_cmp);
+}
+
 /* Lay out the type T, and its element type, and so on.  */
 
 static void
index 872bd5823c5065407a3c66a305994ead032b9f35..8ecafb3cf5ca09fe251c1675dae502a45a37a45b 100644 (file)
@@ -22,6 +22,13 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "c-family/c-common.h"
 
+/* In a RECORD_TYPE, a sorted array of the fields of the type, not a
+   tree for size reasons.  */
+struct GTY(()) sorted_fields_type {
+  int len;
+  tree GTY((length ("%h.len"))) elts[1];
+};
+
 struct GTY(()) lang_type {
   /* In a RECORD_TYPE, a sorted array of the fields of the type.  */
   struct sorted_fields_type * GTY ((reorder ("resort_sorted_fields"))) s;