if (TREE_CODE (exp) == COMPONENT_REF
&& DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1))
/* If it's thinner than an int, promote it like a
- C_PROMOTING_INTEGER_TYPE_P, otherwise leave it alone. */
+ c_promoting_integer_type_p, otherwise leave it alone. */
&& 0 > compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)),
TYPE_PRECISION (integer_type_node)))
return convert (flag_traditional && TREE_UNSIGNED (type)
? unsigned_type_node : integer_type_node,
exp);
- if (C_PROMOTING_INTEGER_TYPE_P (type))
+ if (c_promoting_integer_type_p (type))
{
/* Traditionally, unsignedness is preserved in default promotions.
Also preserve unsignedness if not really getting any wider. */
return convert (integer_type_node, exp);
}
- if (code == BOOLEAN_TYPE)
- return convert (integer_type_node, exp);
-
if (flag_traditional && !flag_allow_single_precision
&& TYPE_MAIN_VARIANT (type) == float_type_node)
return convert (double_type_node, exp);
if (formal_prec == TYPE_PRECISION (float_type_node))
warn_for_assignment ("%s as `float' rather than `double' due to prototype", (char *) 0, name, parmnum + 1);
}
- /* Detect integer changing in width or signedness. */
- else if (INTEGRAL_TYPE_P (type)
+ /* Detect integer changing in width or signedness.
+ These warnings are only activated with
+ -Wconversion, not with -Wtraditional. */
+ else if (warn_conversion && INTEGRAL_TYPE_P (type)
&& INTEGRAL_TYPE_P (TREE_TYPE (val)))
{
tree would_have_been = default_conversion (val);
else if (TYPE_PRECISION (TREE_TYPE (val)) < TYPE_PRECISION (type)
&& TREE_UNSIGNED (TREE_TYPE (val)))
;
- /* These warnings are only activated with
- -Wconversion, not with -Wtraditional. */
- else if (warn_conversion)
- {
- if (TREE_UNSIGNED (type))
- warn_for_assignment ("%s as unsigned due to prototype", (char *) 0, name, parmnum + 1);
- else
- warn_for_assignment ("%s as signed due to prototype", (char *) 0, name, parmnum + 1);
- }
+ else if (TREE_UNSIGNED (type))
+ warn_for_assignment ("%s as unsigned due to prototype", (char *) 0, name, parmnum + 1);
+ else
+ warn_for_assignment ("%s as signed due to prototype", (char *) 0, name, parmnum + 1);
}
}
fundecl, name, parmnum + 1);
if (PROMOTE_PROTOTYPES
- && (TREE_CODE (type) == INTEGER_TYPE
- || TREE_CODE (type) == ENUMERAL_TYPE
- || TREE_CODE (type) == BOOLEAN_TYPE)
+ && INTEGRAL_TYPE_P (type)
&& (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
parmval = default_conversion (parmval);
}
if (TREE_CHAIN (list) == 0)
{
+ /* Convert arrays to pointers when there really is a comma operator. */
+ if (!first_p && TREE_CODE (TREE_TYPE (TREE_VALUE (list))) == ARRAY_TYPE)
+ TREE_VALUE (list) = default_conversion (TREE_VALUE (list));
+
#if 0 /* If something inside inhibited lvalueness, we should not override. */
/* Consider (x, y+0), which is not an lvalue since y+0 is not. */
return TREE_VALUE (list);
}
- if (TREE_CHAIN (list) != 0 && TREE_CHAIN (TREE_CHAIN (list)) == 0)
- {
- /* Convert arrays to pointers when there really is a comma operator. */
- if (TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (list)))) == ARRAY_TYPE)
- TREE_VALUE (TREE_CHAIN (list))
- = default_conversion (TREE_VALUE (TREE_CHAIN (list)));
- }
-
rest = internal_build_compound_expr (TREE_CHAIN (list), FALSE);
if (! TREE_SIDE_EFFECTS (TREE_VALUE (list)))
return error_mark_node;
}
- if (type == TREE_TYPE (value))
+ if (type == TYPE_MAIN_VARIANT (TREE_TYPE (value)))
{
if (pedantic)
{
return value;
}
+
+/* Interpret a cast of expression EXPR to type TYPE. */
+tree
+c_cast_expr (type, expr)
+ tree type, expr;
+{
+ int saved_wsp = warn_strict_prototypes;
+
+ /* This avoids warnings about unprototyped casts on
+ integers. E.g. "#define SIG_DFL (void(*)())0". */
+ if (TREE_CODE (expr) == INTEGER_CST)
+ warn_strict_prototypes = 0;
+ type = groktypename (type);
+ warn_strict_prototypes = saved_wsp;
+
+ return build_c_cast (type, expr);
+}
+
\f
/* Build an assignment expression of lvalue LHS from value RHS.
MODIFYCODE is the code for a binary operator that we use
if (flag_pedantic_errors)
inside_init = error_mark_node;
}
- else if (require_constant && ! TREE_CONSTANT (inside_init))
+ else if (require_constant
+ && (!TREE_CONSTANT (inside_init)
+ /* This test catches things like `7 / 0' which
+ result in an expression for which TREE_CONSTANT
+ is true, but which is not actually something
+ that is a legal constant. We really should not
+ be using this function, because it is a part of
+ the back-end. Instead, the expression should
+ already have been turned into ERROR_MARK_NODE. */
+ || !initializer_constant_valid_p (inside_init,
+ TREE_TYPE (inside_init))))
{
error_init ("initializer element is not constant");
inside_init = error_mark_node;
}
- else if (require_constant
- && initializer_constant_valid_p (inside_init, TREE_TYPE (inside_init)) == 0)
- pedwarn ("initializer element is not computable at load time");
return inside_init;
}
constructor_range_stack = 0;
}
\f
+/* Build a simple asm-statement, from one string literal. */
+tree
+simple_asm_stmt (expr)
+ tree expr;
+{
+ STRIP_NOPS (expr);
+
+ if (TREE_CODE (expr) == ADDR_EXPR)
+ expr = TREE_OPERAND (expr, 0);
+
+ if (TREE_CODE (expr) == STRING_CST)
+ {
+ tree stmt;
+
+ if (TREE_CHAIN (expr))
+ expr = combine_strings (expr);
+ stmt = add_stmt (build_stmt (ASM_STMT, NULL_TREE, expr,
+ NULL_TREE, NULL_TREE,
+ NULL_TREE));
+ ASM_INPUT_P (stmt) = 1;
+ return stmt;
+ }
+
+ error ("argument of `asm' is not a constant string");
+ return NULL_TREE;
+}
+
/* Build an asm-statement, whose components are a CV_QUALIFIER, a
STRING, some OUTPUTS, some INPUTS, and some CLOBBERS. */