+2004-10-08 Joseph S. Myers <jsm@polyomino.org.uk>
+
+ * c-typeck.c (enum impl_conv): Add ic_argpass_nonproto.
+ (convert_for_assignment): Handle ic_argpass_nonproto. Add
+ comments about its relevance to errors.
+ (c_convert_parm_for_inlining): Use ic_argpass_nonproto.
+
2004-10-08 Andrew Pinski <pinskia@physics.uc.edu>
PR c/16999
diagnostic messages in convert_for_assignment. */
enum impl_conv {
ic_argpass,
+ ic_argpass_nonproto,
ic_assign,
ic_init,
ic_return
enum tree_code coder;
tree rname = NULL_TREE;
- if (errtype == ic_argpass)
+ if (errtype == ic_argpass || errtype == ic_argpass_nonproto)
{
tree selector;
/* Change pointer to function to the function itself for
case ic_argpass: \
pedwarn (AR, parmnum, rname); \
break; \
+ case ic_argpass_nonproto: \
+ warning (AR, parmnum, rname); \
+ break; \
case ic_assign: \
pedwarn (AS); \
break; \
if (coder == VOID_TYPE)
{
+ /* Except for passing an argument to an unprototyped function,
+ this is a constraint violation. When passing an argument to
+ an unprototyped function, it is compile-time undefined;
+ making it a constraint in that case was rejected in
+ DR#252. */
error ("void value not ignored as it ought to be");
return error_mark_node;
}
/* Conversion to a transparent union from its member types.
This applies only to function arguments. */
else if (codel == UNION_TYPE && TYPE_TRANSPARENT_UNION (type)
- && errtype == ic_argpass)
+ && (errtype == ic_argpass || errtype == ic_argpass_nonproto))
{
tree memb_types;
tree marginal_memb_type = 0;
}
else if (codel == POINTER_TYPE && coder == ARRAY_TYPE)
{
+ /* ??? This should not be an error when inlining calls to
+ unprototyped functions. */
error ("invalid use of non-lvalue array");
return error_mark_node;
}
switch (errtype)
{
case ic_argpass:
+ case ic_argpass_nonproto:
+ /* ??? This should not be an error when inlining calls to
+ unprototyped functions. */
error ("incompatible type for argument %d of %qE", parmnum, rname);
break;
case ic_assign:
type = TREE_TYPE (parm);
ret = convert_for_assignment (type, value,
- ic_argpass, fn,
+ ic_argpass_nonproto, fn,
fn, argnum);
if (targetm.calls.promote_prototypes (TREE_TYPE (fn))
&& INTEGRAL_TYPE_P (type)
--- /dev/null
+/* Test diagnostics for bad type conversion when inlining unprototyped
+ functions: should not be errors with -pedantic-errors. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "-O3 -std=c99 -pedantic-errors" } */
+
+/* This is valid to execute, so maybe shouldn't warn at all. */
+void f0(x) signed char *x; { }
+void g0(unsigned char *x) { f0(x); } /* { dg-warning "warning: pointer targets in passing argument 1 of 'f0' differ in signedness" } */
+
+/* This is undefined on execution but still must compile. */
+void f1(x) int *x; { }
+void g1(unsigned int *x) { f1(x); } /* { dg-warning "warning: pointer targets in passing argument 1 of 'f1' differ in signedness" } */