]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/c/c-decl.c
Merge with trunk.
[thirdparty/gcc.git] / gcc / c / c-decl.c
index 9520e4d2d6ef4644a4d61cf8e913b93b11cc5333..4afe0f401a90cd35240a5516903b66c97de30f9c 100644 (file)
@@ -4831,14 +4831,14 @@ check_bitfield_type_and_width (tree *type, tree *width, tree orig_name)
       *width = build_int_cst (integer_type_node, w);
     }
   else
-    w = tree_low_cst (*width, 1);
+    w = tree_to_uhwi (*width);
 
   if (TREE_CODE (*type) == ENUMERAL_TYPE)
     {
       struct lang_type *lt = TYPE_LANG_SPECIFIC (*type);
       if (!lt
-         || w < tree_int_cst_min_precision (lt->enum_min, TYPE_UNSIGNED (*type))
-         || w < tree_int_cst_min_precision (lt->enum_max, TYPE_UNSIGNED (*type)))
+         || w < tree_int_cst_min_precision (lt->enum_min, TYPE_SIGN (*type))
+         || w < tree_int_cst_min_precision (lt->enum_max, TYPE_SIGN (*type)))
        warning (0, "%qs is narrower than values of its type", name);
     }
 }
@@ -5910,7 +5910,7 @@ grokdeclarator (const struct c_declarator *declarator,
       else
        error_at (loc, "size of unnamed array is too large");
       /* If we proceed with the array type as it is, we'll eventually
-        crash in tree_low_cst().  */
+        crash in tree_to_uhwi ().  */
       type = error_mark_node;
     }
 
@@ -7261,7 +7261,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
 
       if (DECL_INITIAL (x))
        {
-         unsigned HOST_WIDE_INT width = tree_low_cst (DECL_INITIAL (x), 1);
+         unsigned HOST_WIDE_INT width = tree_to_uhwi (DECL_INITIAL (x));
          DECL_SIZE (x) = bitsize_int (width);
          DECL_BIT_FIELD (x) = 1;
          SET_DECL_C_BIT_FIELD (x);
@@ -7332,7 +7332,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
          && TREE_TYPE (*fieldlistp) != error_mark_node)
        {
          unsigned HOST_WIDE_INT width
-           = tree_low_cst (DECL_INITIAL (*fieldlistp), 1);
+           = tree_to_uhwi (DECL_INITIAL (*fieldlistp));
          tree type = TREE_TYPE (*fieldlistp);
          if (width != TYPE_PRECISION (type))
            {
@@ -7558,7 +7558,8 @@ finish_enum (tree enumtype, tree values, tree attributes)
 {
   tree pair, tem;
   tree minnode = 0, maxnode = 0;
-  int precision, unsign;
+  int precision; 
+  signop sign;
   bool toplevel = (file_scope == current_scope);
   struct lang_type *lt;
 
@@ -7585,13 +7586,13 @@ finish_enum (tree enumtype, tree values, tree attributes)
      as one of the integral types - the narrowest one that fits, except
      that normally we only go as narrow as int - and signed iff any of
      the values are negative.  */
-  unsign = (tree_int_cst_sgn (minnode) >= 0);
-  precision = MAX (tree_int_cst_min_precision (minnode, unsign),
-                  tree_int_cst_min_precision (maxnode, unsign));
+  sign = (tree_int_cst_sgn (minnode) >= 0) ? UNSIGNED : SIGNED;
+  precision = MAX (tree_int_cst_min_precision (minnode, sign),
+                  tree_int_cst_min_precision (maxnode, sign));
 
   if (TYPE_PACKED (enumtype) || precision > TYPE_PRECISION (integer_type_node))
     {
-      tem = c_common_type_for_size (precision, unsign);
+      tem = c_common_type_for_size (precision, sign == UNSIGNED ? 1 : 0);
       if (tem == NULL)
        {
          warning (0, "enumeration values exceed range of largest integer");
@@ -7599,7 +7600,7 @@ finish_enum (tree enumtype, tree values, tree attributes)
        }
     }
   else
-    tem = unsign ? unsigned_type_node : integer_type_node;
+    tem = sign == UNSIGNED ? unsigned_type_node : integer_type_node;
 
   TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (tem);
   TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (tem);