This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][C] Avoid passing NULL to build_int_cst
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Wed, 4 May 2011 14:35:38 +0200 (CEST)
- Subject: [PATCH][C] Avoid passing NULL to build_int_cst
This is the C family parts, bootstrapped and tested on
x86_64-unknown-linux-gnu.
Ok for trunk?
Thanks,
Richard.
2011-05-04 Richard Guenther <rguenther@suse.de>
* c-decl.c (check_bitfield_type_and_width): Do not pass NULL
to build_int_cst.
* c-typeck.c (really_start_incremental_init): Use bitsize_int
for constructor indices.
(push_init_level): Likewise.
c-family/
* c-common.c (fix_string_type): Use size_int for index type bounds.
(start_fname_decls): Do not pass NULL to build_int_cst.
(c_init_attributes): Likewise.
* c-lex.c (c_lex_with_flags): Likewise.
Index: gcc/c-decl.c
===================================================================
*** gcc/c-decl.c (revision 173370)
--- gcc/c-decl.c (working copy)
*************** check_bitfield_type_and_width (tree *typ
*** 4717,4723 ****
{
error ("width of %qs exceeds its type", name);
w = max_width;
! *width = build_int_cst (NULL_TREE, w);
}
else
w = tree_low_cst (*width, 1);
--- 4717,4723 ----
{
error ("width of %qs exceeds its type", name);
w = max_width;
! *width = build_int_cst (integer_type_node, w);
}
else
w = tree_low_cst (*width, 1);
Index: gcc/c-typeck.c
===================================================================
*** gcc/c-typeck.c (revision 173370)
--- gcc/c-typeck.c (working copy)
*************** really_start_incremental_init (tree type
*** 6636,6642 ****
{
/* Vectors are like simple fixed-size arrays. */
constructor_max_index =
! build_int_cst (NULL_TREE, TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
constructor_index = bitsize_zero_node;
constructor_unfilled_index = constructor_index;
}
--- 6636,6642 ----
{
/* Vectors are like simple fixed-size arrays. */
constructor_max_index =
! bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
constructor_index = bitsize_zero_node;
constructor_unfilled_index = constructor_index;
}
*************** push_init_level (int implicit, struct ob
*** 6805,6812 ****
{
/* Vectors are like simple fixed-size arrays. */
constructor_max_index =
! build_int_cst (NULL_TREE, TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
! constructor_index = convert (bitsizetype, integer_zero_node);
constructor_unfilled_index = constructor_index;
}
else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
--- 6805,6812 ----
{
/* Vectors are like simple fixed-size arrays. */
constructor_max_index =
! bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
! constructor_index = bitsize_int (0);
constructor_unfilled_index = constructor_index;
}
else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
Index: gcc/c-family/c-common.c
===================================================================
*** gcc/c-family/c-common.c (revision 173370)
--- gcc/c-family/c-common.c (working copy)
*************** start_fname_decls (void)
*** 743,749 ****
if (decl)
{
! saved = tree_cons (decl, build_int_cst (NULL_TREE, ix), saved);
*fname_vars[ix].decl = NULL_TREE;
}
}
--- 743,750 ----
if (decl)
{
! saved = tree_cons (decl, build_int_cst (integer_type_node, ix),
! saved);
*fname_vars[ix].decl = NULL_TREE;
}
}
*************** fix_string_type (tree value)
*** 946,952 ****
construct the matching unqualified array type first. The C front
end does not require this, but it does no harm, so we do it
unconditionally. */
! i_type = build_index_type (build_int_cst (NULL_TREE, nchars - 1));
a_type = build_array_type (e_type, i_type);
if (c_dialect_cxx() || warn_write_strings)
a_type = c_build_qualified_type (a_type, TYPE_QUAL_CONST);
--- 947,953 ----
construct the matching unqualified array type first. The C front
end does not require this, but it does no harm, so we do it
unconditionally. */
! i_type = build_index_type (size_int (nchars - 1));
a_type = build_array_type (e_type, i_type);
if (c_dialect_cxx() || warn_write_strings)
a_type = c_build_qualified_type (a_type, TYPE_QUAL_CONST);
*************** c_init_attributes (void)
*** 5670,5676 ****
#define DEF_ATTR_NULL_TREE(ENUM) \
built_in_attributes[(int) ENUM] = NULL_TREE;
#define DEF_ATTR_INT(ENUM, VALUE) \
! built_in_attributes[(int) ENUM] = build_int_cst (NULL_TREE, VALUE);
#define DEF_ATTR_IDENT(ENUM, STRING) \
built_in_attributes[(int) ENUM] = get_identifier (STRING);
#define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) \
--- 5671,5677 ----
#define DEF_ATTR_NULL_TREE(ENUM) \
built_in_attributes[(int) ENUM] = NULL_TREE;
#define DEF_ATTR_INT(ENUM, VALUE) \
! built_in_attributes[(int) ENUM] = build_int_cst (integer_type_node, VALUE);
#define DEF_ATTR_IDENT(ENUM, STRING) \
built_in_attributes[(int) ENUM] = get_identifier (STRING);
#define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) \
Index: gcc/c-family/c-lex.c
===================================================================
*** gcc/c-family/c-lex.c (revision 173370)
--- gcc/c-family/c-lex.c (working copy)
*************** c_lex_with_flags (tree *value, location_
*** 437,443 ****
break;
case CPP_PRAGMA:
! *value = build_int_cst (NULL, tok->val.pragma);
break;
/* These tokens should not be visible outside cpplib. */
--- 437,443 ----
break;
case CPP_PRAGMA:
! *value = build_int_cst (integer_type_node, tok->val.pragma);
break;
/* These tokens should not be visible outside cpplib. */