Commit 3ed56f8a by Kaveh R. Ghazi Committed by Kaveh Ghazi

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
parent acb0db7b
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> 2001-04-16 Zack Weinberg <zackw@stanford.edu>
* toplev.c (output_lang_identify): Delete. * toplev.c (output_lang_identify): Delete.
......
...@@ -1709,8 +1709,10 @@ convert_arguments (typelist, values, name, fundecl) ...@@ -1709,8 +1709,10 @@ convert_arguments (typelist, values, name, fundecl)
if (formal_prec == TYPE_PRECISION (float_type_node)) 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); warn_for_assignment ("%s as `float' rather than `double' due to prototype", (char *) 0, name, parmnum + 1);
} }
/* Detect integer changing in width or signedness. */ /* Detect integer changing in width or signedness.
else if (INTEGRAL_TYPE_P (type) These warnings are only activated with
-Wconversion, not with -Wtraditional. */
else if (warn_conversion && INTEGRAL_TYPE_P (type)
&& INTEGRAL_TYPE_P (TREE_TYPE (val))) && INTEGRAL_TYPE_P (TREE_TYPE (val)))
{ {
tree would_have_been = default_conversion (val); tree would_have_been = default_conversion (val);
...@@ -1755,15 +1757,10 @@ convert_arguments (typelist, values, name, fundecl) ...@@ -1755,15 +1757,10 @@ convert_arguments (typelist, values, name, fundecl)
else if (TYPE_PRECISION (TREE_TYPE (val)) < TYPE_PRECISION (type) else if (TYPE_PRECISION (TREE_TYPE (val)) < TYPE_PRECISION (type)
&& TREE_UNSIGNED (TREE_TYPE (val))) && TREE_UNSIGNED (TREE_TYPE (val)))
; ;
/* These warnings are only activated with else if (TREE_UNSIGNED (type))
-Wconversion, not with -Wtraditional. */ warn_for_assignment ("%s as unsigned due to prototype", (char *) 0, name, parmnum + 1);
else if (warn_conversion) else
{ warn_for_assignment ("%s as signed due to prototype", (char *) 0, name, parmnum + 1);
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);
}
} }
} }
......
...@@ -2125,9 +2125,10 @@ initializer warnings and relies on default initialization to zero in the ...@@ -2125,9 +2125,10 @@ initializer warnings and relies on default initialization to zero in the
traditional C case. traditional C case.
@item @item
Conversions by prototypes. This is similar to @samp{-Wconversion} in Conversions by prototypes between fixed/floating point values and vice
that it warns about width changes and fixed/floating point conversions, versa. The absence of these prototypes when compiling with traditional
however it does not warn about changes in signedness. C would cause serious problems. This is a subset of the possible
conversion warnings, for the full set use @samp{-Wconversion}.
@end itemize @end itemize
@item -Wundef @item -Wundef
......
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> 2001-04-12 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.abi/primary3.C (main): Correct expected layout. * g++.old-deja/g++.abi/primary3.C (main): Correct expected layout.
......
...@@ -4,14 +4,12 @@ ...@@ -4,14 +4,12 @@
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-Wtraditional" } */ /* { dg-options "-Wtraditional" } */
extern void foo_c (char); extern void foo_i (int);
extern void foo_ll (long long);
extern void foo_f (float); extern void foo_f (float);
extern void foo_ld (long double); extern void foo_ld (long double);
extern void foo_cd (__complex__ double); extern void foo_cd (__complex__ double);
extern char c; extern int i;
extern long long ll;
extern float f; extern float f;
extern long double ld; extern long double ld;
extern __complex__ double cd; extern __complex__ double cd;
...@@ -19,32 +17,22 @@ extern __complex__ double cd; ...@@ -19,32 +17,22 @@ extern __complex__ double cd;
void void
testfunc1 (void) testfunc1 (void)
{ {
foo_c (c); /* { dg-warning "with different width" "prototype conversion warning" } */ foo_i (i);
foo_c (ll); /* { dg-warning "with different width" "prototype conversion warning" } */ foo_i (f); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */
foo_c (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_c (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_c (cd); /* { dg-warning "as integer rather than complex" "prototype conversion warning" } */
foo_ll (c); /* { dg-warning "with different width" "prototype conversion warning" } */ foo_f (i); /* { dg-warning "as floating rather than integer" "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 (f); /* { dg-warning "as `float' rather than `double'" "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 (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_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 (i); /* { 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 (f); foo_ld (f);
foo_ld (ld); foo_ld (ld);
foo_ld (cd); /* { dg-warning "as floating rather than complex" "prototype conversion warning" } */ 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 (i); /* { 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 (f); /* { dg-warning "as complex rather than floating" "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 (ld); /* { dg-warning "as complex rather than floating" "prototype conversion warning" } */
foo_cd (cd); foo_cd (cd);
...@@ -56,32 +44,22 @@ testfunc1 (void) ...@@ -56,32 +44,22 @@ testfunc1 (void)
void void
testfunc2 (void) testfunc2 (void)
{ {
foo_c (c); foo_i (i);
foo_c (ll); foo_i (f);
foo_c (f); foo_i (ld);
foo_c (ld); foo_i (cd);
foo_c (cd);
foo_ll (c);
foo_ll (ll);
foo_ll (f);
foo_ll (ld);
foo_ll (cd);
foo_f (c); foo_f (i);
foo_f (ll);
foo_f (f); foo_f (f);
foo_f (ld); foo_f (ld);
foo_f (cd); foo_f (cd);
foo_ld (c); foo_ld (i);
foo_ld (ll);
foo_ld (f); foo_ld (f);
foo_ld (ld); foo_ld (ld);
foo_ld (cd); foo_ld (cd);
foo_cd (c); foo_cd (i);
foo_cd (ll);
foo_cd (f); foo_cd (f);
foo_cd (ld); foo_cd (ld);
foo_cd (cd); foo_cd (cd);
......
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