From: Kaveh R. Ghazi Date: Tue, 17 Apr 2001 02:21:10 +0000 (+0000) Subject: c-typeck.c (convert_arguments): Don't check for width changes with -Wtraditional. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3ed56f8a0e57bd184b5926c6396feaf23ab2cbcb;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 628f5281d59..b2413d1f44f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2001-04-16 Kaveh R. Ghazi + + * c-typeck.c (convert_arguments): Don't check for width changes + with -Wtraditional. + + * invoke.texi (-Wtraditional): Update documentation. + 2001-04-16 Zack Weinberg * toplev.c (output_lang_identify): Delete. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 400e80d150c..baf5fed2d07 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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); } } diff --git a/gcc/invoke.texi b/gcc/invoke.texi index b795b576d3f..9762596ad79 100644 --- a/gcc/invoke.texi +++ b/gcc/invoke.texi @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ea72f127ae1..7a18d157f38 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-04-16 Kaveh R. Ghazi + + * gcc.dg/wtr-conversion-1.c: Don't test for width changes. + 2001-04-12 Nathan Sidwell * g++.old-deja/g++.abi/primary3.C (main): Correct expected layout. diff --git a/gcc/testsuite/gcc.dg/wtr-conversion-1.c b/gcc/testsuite/gcc.dg/wtr-conversion-1.c index 57dd818be52..ecf688fe405 100644 --- a/gcc/testsuite/gcc.dg/wtr-conversion-1.c +++ b/gcc/testsuite/gcc.dg/wtr-conversion-1.c @@ -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_ll (c); - foo_ll (ll); - foo_ll (f); - foo_ll (ld); - foo_ll (cd); + foo_i (i); + foo_i (f); + foo_i (ld); + foo_i (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);