Commit f6d1c3a6 by Joseph Myers Committed by Joseph Myers

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
parent e498b9f1
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> 2005-03-20 Kazu Hirata <kazu@cs.umass.edu>
* builtins.c (fold_fixed_mathfn, fold_builtin_trunc, * builtins.c (fold_fixed_mathfn, fold_builtin_trunc,
......
...@@ -4481,12 +4481,6 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args, ...@@ -4481,12 +4481,6 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
else if (TYPE_P (*node)) else if (TYPE_P (*node))
type = node, is_type = 1; 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) if (TREE_CODE (align_expr) != INTEGER_CST)
{ {
error ("requested alignment is not a constant"); error ("requested alignment is not a constant");
...@@ -5119,7 +5113,6 @@ check_function_sentinel (tree attrs, tree params) ...@@ -5119,7 +5113,6 @@ check_function_sentinel (tree attrs, tree params)
if (TREE_VALUE (attr)) if (TREE_VALUE (attr))
{ {
tree p = TREE_VALUE (TREE_VALUE (attr)); tree p = TREE_VALUE (TREE_VALUE (attr));
STRIP_NOPS (p);
pos = TREE_INT_CST_LOW (p); pos = TREE_INT_CST_LOW (p);
} }
...@@ -5199,13 +5192,7 @@ check_nonnull_arg (void * ARG_UNUSED (ctx), tree param, ...@@ -5199,13 +5192,7 @@ check_nonnull_arg (void * ARG_UNUSED (ctx), tree param,
static bool static bool
get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp) get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp)
{ {
/* Strip any conversions from the arg number and verify they /* Verify the arg number is a constant. */
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);
if (TREE_CODE (arg_num_expr) != INTEGER_CST if (TREE_CODE (arg_num_expr) != INTEGER_CST
|| TREE_INT_CST_HIGH (arg_num_expr) != 0) || TREE_INT_CST_HIGH (arg_num_expr) != 0)
return false; return false;
...@@ -5324,7 +5311,6 @@ handle_sentinel_attribute (tree *node, tree name, tree args, ...@@ -5324,7 +5311,6 @@ handle_sentinel_attribute (tree *node, tree name, tree args,
{ {
tree position = TREE_VALUE (args); tree position = TREE_VALUE (args);
STRIP_NOPS (position);
if (TREE_CODE (position) != INTEGER_CST) if (TREE_CODE (position) != INTEGER_CST)
{ {
warning ("requested position is not an integer constant"); warning ("requested position is not an integer constant");
...@@ -5402,10 +5388,6 @@ check_function_arguments_recurse (void (*callback) ...@@ -5402,10 +5388,6 @@ check_function_arguments_recurse (void (*callback)
/* Extract the argument number, which was previously checked /* Extract the argument number, which was previously checked
to be valid. */ to be valid. */
format_num_expr = TREE_VALUE (TREE_VALUE (attrs)); 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 gcc_assert (TREE_CODE (format_num_expr) == INTEGER_CST
&& !TREE_INT_CST_HIGH (format_num_expr)); && !TREE_INT_CST_HIGH (format_num_expr));
......
...@@ -3637,9 +3637,6 @@ check_bitfield_type_and_width (tree *type, tree *width, const char *orig_name) ...@@ -3637,9 +3637,6 @@ check_bitfield_type_and_width (tree *type, tree *width, const char *orig_name)
unsigned HOST_WIDE_INT w; unsigned HOST_WIDE_INT w;
const char *name = orig_name ? orig_name: _("<anonymous>"); const char *name = orig_name ? orig_name: _("<anonymous>");
/* Necessary? */
STRIP_NOPS (*width);
/* Detect and ignore out of range field width and process valid /* Detect and ignore out of range field width and process valid
field widths. */ field widths. */
if (!INTEGRAL_TYPE_P (TREE_TYPE (*width)) if (!INTEGRAL_TYPE_P (TREE_TYPE (*width))
...@@ -5624,10 +5621,6 @@ build_enumerator (tree name, tree value) ...@@ -5624,10 +5621,6 @@ build_enumerator (tree name, tree value)
/* Validate and default VALUE. */ /* Validate and default VALUE. */
/* Remove no-op casts from the value. */
if (value)
STRIP_TYPE_NOPS (value);
if (value != 0) if (value != 0)
{ {
/* Don't issue more errors for error_mark_node (i.e. an /* Don't issue more errors for error_mark_node (i.e. an
......
...@@ -147,17 +147,12 @@ check_format_string (tree argument, unsigned HOST_WIDE_INT format_num, ...@@ -147,17 +147,12 @@ check_format_string (tree argument, unsigned HOST_WIDE_INT format_num,
return true; return true;
} }
/* Strip any conversions from the expression, verify it is a constant, /* Verify EXPR is a constant, and store its value.
and store its value. If validated_p is true, abort on errors. If validated_p is true, abort on errors.
Returns true on success, false otherwise. */ Returns true on success, false otherwise. */
static bool static bool
get_constant (tree expr, unsigned HOST_WIDE_INT *value, int validated_p) 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) if (TREE_CODE (expr) != INTEGER_CST || TREE_INT_CST_HIGH (expr) != 0)
{ {
gcc_assert (!validated_p); gcc_assert (!validated_p);
......
...@@ -5019,7 +5019,6 @@ c_parser_postfix_expression (c_parser *parser) ...@@ -5019,7 +5019,6 @@ c_parser_postfix_expression (c_parser *parser)
tree c; tree c;
c = fold (e1.value); c = fold (e1.value);
STRIP_NOPS (c);
if (TREE_CODE (c) != INTEGER_CST) if (TREE_CODE (c) != INTEGER_CST)
error ("first argument to %<__builtin_choose_expr%> not" error ("first argument to %<__builtin_choose_expr%> not"
" a constant"); " a constant");
......
...@@ -2234,11 +2234,6 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl) ...@@ -2234,11 +2234,6 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl)
/* Change in signedness doesn't matter /* Change in signedness doesn't matter
if a constant value is unaffected. */ 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 /* If the value is extended from a narrower
unsigned type, it doesn't matter whether we unsigned type, it doesn't matter whether we
pass it as signed or unsigned; the value pass it as signed or unsigned; the value
...@@ -5205,21 +5200,6 @@ set_init_index (tree first, tree last) ...@@ -5205,21 +5200,6 @@ set_init_index (tree first, tree last)
return; 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) if (TREE_CODE (first) != INTEGER_CST)
error_init ("nonconstant array index in initializer"); error_init ("nonconstant array index in initializer");
else if (last != 0 && TREE_CODE (last) != INTEGER_CST) else if (last != 0 && TREE_CODE (last) != INTEGER_CST)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment