c-typeck.c (convert_arguments): Don't check for width changes with -Wtraditional.

* c-typeck.c (convert_arguments): Don't check for width changes
	with -Wtraditional.

	* invoke.texi (-Wtraditional): Update documentation.

testsuite:
	* gcc.dg/wtr-conversion-1.c: Don't test for width changes.

From-SVN: r41386
This commit is contained in:
Kaveh R. Ghazi 2001-04-17 02:21:10 +00:00 committed by Kaveh Ghazi
parent acb0db7b38
commit 3ed56f8a0e
5 changed files with 39 additions and 52 deletions

View File

@ -1,3 +1,10 @@
2001-04-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* c-typeck.c (convert_arguments): Don't check for width changes
with -Wtraditional.
* invoke.texi (-Wtraditional): Update documentation.
2001-04-16 Zack Weinberg <zackw@stanford.edu>
* toplev.c (output_lang_identify): Delete.

View File

@ -1709,8 +1709,10 @@ convert_arguments (typelist, values, name, fundecl)
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);
@ -1755,15 +1757,10 @@ convert_arguments (typelist, values, name, fundecl)
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);
}
}

View File

@ -2125,9 +2125,10 @@ initializer warnings and relies on default initialization to zero in the
traditional C case.
@item
Conversions by prototypes. This is similar to @samp{-Wconversion} in
that it warns about width changes and fixed/floating point conversions,
however it does not warn about changes in signedness.
Conversions by prototypes between fixed/floating point values and vice
versa. The absence of these prototypes when compiling with traditional
C would cause serious problems. This is a subset of the possible
conversion warnings, for the full set use @samp{-Wconversion}.
@end itemize
@item -Wundef

View File

@ -1,3 +1,7 @@
2001-04-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/wtr-conversion-1.c: Don't test for width changes.
2001-04-12 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.abi/primary3.C (main): Correct expected layout.

View File

@ -4,14 +4,12 @@
/* { dg-do compile } */
/* { dg-options "-Wtraditional" } */
extern void foo_c (char);
extern void foo_ll (long long);
extern void foo_i (int);
extern void foo_f (float);
extern void foo_ld (long double);
extern void foo_cd (__complex__ double);
extern char c;
extern long long ll;
extern int i;
extern float f;
extern long double ld;
extern __complex__ double cd;
@ -19,32 +17,22 @@ extern __complex__ double cd;
void
testfunc1 (void)
{
foo_c (c); /* { dg-warning "with different width" "prototype conversion warning" } */
foo_c (ll); /* { dg-warning "with different width" "prototype conversion warning" } */
foo_c (f); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */
foo_c (ld); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */
foo_c (cd); /* { dg-warning "as integer rather than complex" "prototype conversion warning" } */
foo_i (i);
foo_i (f); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */
foo_i (ld); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */
foo_i (cd); /* { dg-warning "as integer rather than complex" "prototype conversion warning" } */
foo_ll (c); /* { dg-warning "with different width" "prototype conversion warning" } */
foo_ll (ll);
foo_ll (f); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */
foo_ll (ld); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */
foo_ll (cd); /* { dg-warning "as integer rather than complex" "prototype conversion warning" } */
foo_f (c); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */
foo_f (ll); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */
foo_f (i); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */
foo_f (f); /* { dg-warning "as `float' rather than `double'" "prototype conversion warning" } */
foo_f (ld); /* { dg-warning "as `float' rather than `double'" "prototype conversion warning" } */
foo_f (cd); /* { dg-warning "as floating rather than complex" "prototype conversion warning" } */
foo_ld (c); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */
foo_ld (ll); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */
foo_ld (i); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */
foo_ld (f);
foo_ld (ld);
foo_ld (cd); /* { dg-warning "as floating rather than complex" "prototype conversion warning" } */
foo_cd (c); /* { dg-warning "as complex rather than integer" "prototype conversion warning" } */
foo_cd (ll); /* { dg-warning "as complex rather than integer" "prototype conversion warning" } */
foo_cd (i); /* { dg-warning "as complex rather than integer" "prototype conversion warning" } */
foo_cd (f); /* { dg-warning "as complex rather than floating" "prototype conversion warning" } */
foo_cd (ld); /* { dg-warning "as complex rather than floating" "prototype conversion warning" } */
foo_cd (cd);
@ -56,32 +44,22 @@ testfunc1 (void)
void
testfunc2 (void)
{
foo_c (c);
foo_c (ll);
foo_c (f);
foo_c (ld);
foo_c (cd);
foo_i (i);
foo_i (f);
foo_i (ld);
foo_i (cd);
foo_ll (c);
foo_ll (ll);
foo_ll (f);
foo_ll (ld);
foo_ll (cd);
foo_f (c);
foo_f (ll);
foo_f (i);
foo_f (f);
foo_f (ld);
foo_f (cd);
foo_ld (c);
foo_ld (ll);
foo_ld (i);
foo_ld (f);
foo_ld (ld);
foo_ld (cd);
foo_cd (c);
foo_cd (ll);
foo_cd (i);
foo_cd (f);
foo_cd (ld);
foo_cd (cd);