c-common.c (handle_aligned_attribute, [...]): Do not strip NOPS from INTEGER_CSTs.

* c-common.c (handle_aligned_attribute, check_function_sentinel,
	get_nonnull_operand, handle_sentinel_attribute,
	check_function_arguments_recurse): Do not strip NOPS from
	INTEGER_CSTs.
	* c-decl.c (check_bitfield_type_and_width, build_enumerator):
	Likewise.
	* c-format.c (get_constant): Likewise.
	* c-parser.c (c_parser_postfix_expression): Likewise.
	* c-typeck.c (set_init_index): Likewise.
	(convert_arguments): Don't check for NOP_EXPR containing integer
	constant.

From-SVN: r96760
This commit is contained in:
Joseph Myers 2005-03-20 15:23:50 +00:00 committed by Joseph Myers
parent e498b9f1a0
commit f6d1c3a69b
6 changed files with 17 additions and 54 deletions

View File

@ -1,3 +1,17 @@
2005-03-20 Joseph S. Myers <joseph@codesourcery.com>
* c-common.c (handle_aligned_attribute, check_function_sentinel,
get_nonnull_operand, handle_sentinel_attribute,
check_function_arguments_recurse): Do not strip NOPS from
INTEGER_CSTs.
* c-decl.c (check_bitfield_type_and_width, build_enumerator):
Likewise.
* c-format.c (get_constant): Likewise.
* c-parser.c (c_parser_postfix_expression): Likewise.
* c-typeck.c (set_init_index): Likewise.
(convert_arguments): Don't check for NOP_EXPR containing integer
constant.
2005-03-20 Kazu Hirata <kazu@cs.umass.edu>
* builtins.c (fold_fixed_mathfn, fold_builtin_trunc,

View File

@ -4481,12 +4481,6 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
else if (TYPE_P (*node))
type = node, is_type = 1;
/* Strip any NOPs of any kind. */
while (TREE_CODE (align_expr) == NOP_EXPR
|| TREE_CODE (align_expr) == CONVERT_EXPR
|| TREE_CODE (align_expr) == NON_LVALUE_EXPR)
align_expr = TREE_OPERAND (align_expr, 0);
if (TREE_CODE (align_expr) != INTEGER_CST)
{
error ("requested alignment is not a constant");
@ -5119,7 +5113,6 @@ check_function_sentinel (tree attrs, tree params)
if (TREE_VALUE (attr))
{
tree p = TREE_VALUE (TREE_VALUE (attr));
STRIP_NOPS (p);
pos = TREE_INT_CST_LOW (p);
}
@ -5199,13 +5192,7 @@ check_nonnull_arg (void * ARG_UNUSED (ctx), tree param,
static bool
get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp)
{
/* Strip any conversions from the arg number and verify they
are constants. */
while (TREE_CODE (arg_num_expr) == NOP_EXPR
|| TREE_CODE (arg_num_expr) == CONVERT_EXPR
|| TREE_CODE (arg_num_expr) == NON_LVALUE_EXPR)
arg_num_expr = TREE_OPERAND (arg_num_expr, 0);
/* Verify the arg number is a constant. */
if (TREE_CODE (arg_num_expr) != INTEGER_CST
|| TREE_INT_CST_HIGH (arg_num_expr) != 0)
return false;
@ -5324,7 +5311,6 @@ handle_sentinel_attribute (tree *node, tree name, tree args,
{
tree position = TREE_VALUE (args);
STRIP_NOPS (position);
if (TREE_CODE (position) != INTEGER_CST)
{
warning ("requested position is not an integer constant");
@ -5402,10 +5388,6 @@ check_function_arguments_recurse (void (*callback)
/* Extract the argument number, which was previously checked
to be valid. */
format_num_expr = TREE_VALUE (TREE_VALUE (attrs));
while (TREE_CODE (format_num_expr) == NOP_EXPR
|| TREE_CODE (format_num_expr) == CONVERT_EXPR
|| TREE_CODE (format_num_expr) == NON_LVALUE_EXPR)
format_num_expr = TREE_OPERAND (format_num_expr, 0);
gcc_assert (TREE_CODE (format_num_expr) == INTEGER_CST
&& !TREE_INT_CST_HIGH (format_num_expr));

View File

@ -3637,9 +3637,6 @@ check_bitfield_type_and_width (tree *type, tree *width, const char *orig_name)
unsigned HOST_WIDE_INT w;
const char *name = orig_name ? orig_name: _("<anonymous>");
/* Necessary? */
STRIP_NOPS (*width);
/* Detect and ignore out of range field width and process valid
field widths. */
if (!INTEGRAL_TYPE_P (TREE_TYPE (*width))
@ -5624,10 +5621,6 @@ build_enumerator (tree name, tree value)
/* Validate and default VALUE. */
/* Remove no-op casts from the value. */
if (value)
STRIP_TYPE_NOPS (value);
if (value != 0)
{
/* Don't issue more errors for error_mark_node (i.e. an

View File

@ -147,17 +147,12 @@ check_format_string (tree argument, unsigned HOST_WIDE_INT format_num,
return true;
}
/* Strip any conversions from the expression, verify it is a constant,
and store its value. If validated_p is true, abort on errors.
/* Verify EXPR is a constant, and store its value.
If validated_p is true, abort on errors.
Returns true on success, false otherwise. */
static bool
get_constant (tree expr, unsigned HOST_WIDE_INT *value, int validated_p)
{
while (TREE_CODE (expr) == NOP_EXPR
|| TREE_CODE (expr) == CONVERT_EXPR
|| TREE_CODE (expr) == NON_LVALUE_EXPR)
expr = TREE_OPERAND (expr, 0);
if (TREE_CODE (expr) != INTEGER_CST || TREE_INT_CST_HIGH (expr) != 0)
{
gcc_assert (!validated_p);

View File

@ -5019,7 +5019,6 @@ c_parser_postfix_expression (c_parser *parser)
tree c;
c = fold (e1.value);
STRIP_NOPS (c);
if (TREE_CODE (c) != INTEGER_CST)
error ("first argument to %<__builtin_choose_expr%> not"
" a constant");

View File

@ -2234,11 +2234,6 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl)
/* Change in signedness doesn't matter
if a constant value is unaffected. */
;
/* Likewise for a constant in a NOP_EXPR. */
else if (TREE_CODE (val) == NOP_EXPR
&& TREE_CODE (TREE_OPERAND (val, 0)) == INTEGER_CST
&& int_fits_type_p (TREE_OPERAND (val, 0), type))
;
/* If the value is extended from a narrower
unsigned type, it doesn't matter whether we
pass it as signed or unsigned; the value
@ -5205,21 +5200,6 @@ set_init_index (tree first, tree last)
return;
}
while ((TREE_CODE (first) == NOP_EXPR
|| TREE_CODE (first) == CONVERT_EXPR
|| TREE_CODE (first) == NON_LVALUE_EXPR)
&& (TYPE_MODE (TREE_TYPE (first))
== TYPE_MODE (TREE_TYPE (TREE_OPERAND (first, 0)))))
first = TREE_OPERAND (first, 0);
if (last)
while ((TREE_CODE (last) == NOP_EXPR
|| TREE_CODE (last) == CONVERT_EXPR
|| TREE_CODE (last) == NON_LVALUE_EXPR)
&& (TYPE_MODE (TREE_TYPE (last))
== TYPE_MODE (TREE_TYPE (TREE_OPERAND (last, 0)))))
last = TREE_OPERAND (last, 0);
if (TREE_CODE (first) != INTEGER_CST)
error_init ("nonconstant array index in initializer");
else if (last != 0 && TREE_CODE (last) != INTEGER_CST)