From 05170031abc9baabb16c0f181228bd9343b0bfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez?= Date: Thu, 23 Nov 2006 18:39:32 +0000 Subject: re PR c/9072 (-Wconversion should be split into two distinct flags) 2006-11-23 Manuel Lopez-Ibanez PR c/9072 * c.opt (Wtraditional-conversion): New. (Wconversion): Update description. * c-typeck.c (convert_arguments): Warnings for prototypes causing type conversions different from what would happen in the absence of prototype are now handled by Wtraditional-conversion. * doc/invoke.texi (Wtraditional-conversion): New. (Wconversion): Update description. * doc/trouble.texi (Wconversion): Replace Wconversion by Wtraditional-conversion. testsuite/ PR c/9072 * gcc.dg/builtin-protos-1.c: Replace Wconversion by Wtraditional-conversion. * gcc.dg/overflow-warn-2.c: Likewise. * gcc.dg/Wconversion.c: Likewise. Renamed as Wtraditional-conversion.c . * gcc.dg/Wconversion-2.c: Likewise. Renamed as Wtraditional-conversion-2.c . * gcc.dg/dfp/Wconversion-2.c: Likewise. Renamed as Wtraditional-conversion-2.c * gcc.dg/Wconversion-negative-constants.c: New. From-SVN: r119129 --- gcc/ChangeLog | 13 +++++ gcc/c-typeck.c | 12 ++-- gcc/c.opt | 6 +- gcc/doc/invoke.texi | 26 +++++---- gcc/doc/trouble.texi | 6 +- gcc/testsuite/ChangeLog | 14 +++++ gcc/testsuite/gcc.dg/Wconversion-2.c | 64 ---------------------- .../gcc.dg/Wconversion-negative-constants.c | 54 ++++++++++++++++++ gcc/testsuite/gcc.dg/Wconversion.c | 20 ------- gcc/testsuite/gcc.dg/Wtraditional-conversion-2.c | 64 ++++++++++++++++++++++ gcc/testsuite/gcc.dg/Wtraditional-conversion.c | 20 +++++++ gcc/testsuite/gcc.dg/builtin-protos-1.c | 2 +- gcc/testsuite/gcc.dg/dfp/Wconversion-2.c | 44 --------------- .../gcc.dg/dfp/Wtraditional-conversion-2.c | 46 ++++++++++++++++ gcc/testsuite/gcc.dg/overflow-warn-2.c | 44 +++++++-------- 15 files changed, 262 insertions(+), 173 deletions(-) delete mode 100644 gcc/testsuite/gcc.dg/Wconversion-2.c create mode 100644 gcc/testsuite/gcc.dg/Wconversion-negative-constants.c delete mode 100644 gcc/testsuite/gcc.dg/Wconversion.c create mode 100644 gcc/testsuite/gcc.dg/Wtraditional-conversion-2.c create mode 100644 gcc/testsuite/gcc.dg/Wtraditional-conversion.c delete mode 100644 gcc/testsuite/gcc.dg/dfp/Wconversion-2.c create mode 100644 gcc/testsuite/gcc.dg/dfp/Wtraditional-conversion-2.c (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cfd031d..f649c7b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2006-11-23 Manuel Lopez-Ibanez + + PR c/9072 + * c.opt (Wtraditional-conversion): New. + (Wconversion): Update description. + * c-typeck.c (convert_arguments): Warnings for prototypes causing + type conversions different from what would happen in the absence + of prototype are now handled by Wtraditional-conversion. + * doc/invoke.texi (Wtraditional-conversion): New. + (Wconversion): Update description. + * doc/trouble.texi (Wconversion): Replace Wconversion by + Wtraditional-conversion. + 2006-11-23 Andrew Pinski * predict.c (tree_estimate_probability): Check to make diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 30b4382..1b0e33a 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2427,7 +2427,7 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl) { /* Optionally warn about conversions that differ from the default conversions. */ - if (warn_conversion || warn_traditional) + if (warn_traditional_conversion || warn_traditional) { unsigned int formal_prec = TYPE_PRECISION (type); @@ -2503,8 +2503,8 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl) } /* 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) + -Wtraditional-conversion, not with -Wtraditional. */ + else if (warn_traditional_conversion && INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (val))) { tree would_have_been = default_conversion (val); @@ -2517,7 +2517,7 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl) and the actual arg is that enum type. */ ; else if (formal_prec != TYPE_PRECISION (type1)) - warning (OPT_Wconversion, "passing argument %d of %qE " + warning (OPT_Wtraditional_conversion, "passing argument %d of %qE " "with different width due to prototype", argnum, rname); else if (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (type1)) @@ -2540,11 +2540,11 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl) && TYPE_UNSIGNED (TREE_TYPE (val))) ; else if (TYPE_UNSIGNED (type)) - warning (OPT_Wconversion, "passing argument %d of %qE " + warning (OPT_Wtraditional_conversion, "passing argument %d of %qE " "as unsigned due to prototype", argnum, rname); else - warning (OPT_Wconversion, "passing argument %d of %qE " + warning (OPT_Wtraditional_conversion, "passing argument %d of %qE " "as signed due to prototype", argnum, rname); } } diff --git a/gcc/c.opt b/gcc/c.opt index 01cb779..6cd1790 100644 --- a/gcc/c.opt +++ b/gcc/c.opt @@ -151,7 +151,7 @@ Synonym for -Wcomment Wconversion C ObjC C++ ObjC++ Var(warn_conversion) -Warn about possibly confusing type conversions +Warn for implicit type conversions that may change a value Wctor-dtor-privacy C++ ObjC++ Var(warn_ctor_dtor_privacy) @@ -399,6 +399,10 @@ Wtraditional C ObjC Var(warn_traditional) Warn about features not present in traditional C +Wtraditional-conversion +C ObjC Var(warn_traditional_conversion) +Warn of prototypes causing type conversions different from what would happen in the absence of prototype + Wtrigraphs C ObjC C++ ObjC++ Warn if trigraphs are encountered that might affect the meaning of the program diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 2cef7e6..9f22681 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -255,7 +255,7 @@ Objective-C and Objective-C++ Dialects}. @item C-only Warning Options @gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol -Wmissing-prototypes -Wnested-externs -Wold-style-definition @gol --Wstrict-prototypes -Wtraditional @gol +-Wstrict-prototypes -Wtraditional -Wtraditional-conversion @gol -Wdeclaration-after-statement -Wpointer-sign} @item Debugging Options @@ -3058,7 +3058,7 @@ traditional C case. 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 @option{-Wconversion}. +conversion warnings, for the full set use @option{-Wtraditional-conversion}. @item Use of ISO C style function definitions. This warning intentionally is @@ -3070,6 +3070,14 @@ because that feature is already a GCC extension and thus not relevant to traditional C compatibility. @end itemize +@item -Wtraditional-conversion @r{(C only)} +@opindex Wtraditional-conversion +Warn if a prototype causes a type conversion that is different from what +would happen to the same argument in the absence of a prototype. This +includes conversions of fixed point to floating and vice versa, and +conversions changing the width or signedness of a fixed point argument +except when the same as the default promotion. + @item -Wdeclaration-after-statement @r{(C only)} @opindex Wdeclaration-after-statement Warn when a declaration is found after a statement in a block. This @@ -3148,16 +3156,10 @@ this is why we did not make @option{-Wall} request these warnings. @item -Wconversion @opindex Wconversion -Warn if a prototype causes a type conversion that is different from what -would happen to the same argument in the absence of a prototype. This -includes conversions of fixed point to floating and vice versa, and -conversions changing the width or signedness of a fixed point argument -except when the same as the default promotion. - -Also, warn if a negative integer constant expression is implicitly -converted to an unsigned type. For example, warn about the assignment -@code{x = -1} if @code{x} is unsigned. But do not warn about explicit -casts like @code{(unsigned) -1}. +Warn if a negative integer constant expression is implicitly converted +to an unsigned type. For example, warn about the assignment +@code{unsigned x = -1} if @code{x} is unsigned. But do not warn about +explicit casts like @code{(unsigned) -1}. @item -Wsign-compare @opindex Wsign-compare diff --git a/gcc/doc/trouble.texi b/gcc/doc/trouble.texi index c65ad70..505f821 100644 --- a/gcc/doc/trouble.texi +++ b/gcc/doc/trouble.texi @@ -985,10 +985,10 @@ you are removing prototypes that were made with @command{protoize}; if the program worked before without any prototypes, it will work again without them. -@opindex Wconversion +@opindex Wtraditional-conversion You can find all the places where this problem might occur by compiling -the program with the @option{-Wconversion} option. It prints a warning -whenever an argument is converted. +the program with the @option{-Wtraditional-conversion} option. It +prints a warning whenever an argument is converted. @item Both conversion programs can be confused if there are macro calls in and diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3fc471e..d78a3e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,17 @@ +2006-11-23 Manuel Lopez-Ibanez + + PR c/9072 + * gcc.dg/builtin-protos-1.c: Replace Wconversion by + Wtraditional-conversion. + * gcc.dg/overflow-warn-2.c: Likewise. + * gcc.dg/Wconversion.c: Likewise. Renamed as + Wtraditional-conversion.c . + * gcc.dg/Wconversion-2.c: Likewise. Renamed as + Wtraditional-conversion-2.c . + * gcc.dg/dfp/Wconversion-2.c: Likewise. Renamed as + Wtraditional-conversion-2.c + * gcc.dg/Wconversion-negative-constants.c: New. + 2006-11-23 Andrew Pinski * gcc.dg/tree-ssa/dump-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/Wconversion-2.c b/gcc/testsuite/gcc.dg/Wconversion-2.c deleted file mode 100644 index 320f41f..0000000 --- a/gcc/testsuite/gcc.dg/Wconversion-2.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Test messages for -Wconversion, including that they are not - pedwarns. */ -/* Origin: Joseph Myers */ -/* { dg-do compile } */ -/* { dg-options "-std=c99 -pedantic-errors -Wconversion" } */ - -void fsc(signed char); -void fsi(signed int); -void fsll(signed long long); -void fuc(unsigned char); -void fui(unsigned int); -void full(unsigned long long); -void ff(float); -void fld(long double); -void fcf(_Complex float); - -struct s { - void (*fsc)(signed char); - void (*fsi)(signed int); - void (*fsll)(signed long long); - void (*fuc)(unsigned char); - void (*fui)(unsigned int); - void (*full)(unsigned long long); - void (*ff)(float); - void (*fld)(long double); - void (*fcf)(_Complex float); -} x; - -signed char sc; -signed int si; -signed long long sll; -unsigned char uc; -unsigned int ui; -unsigned long long ull; -float f; -long double ld; -_Complex float cf; - -void -g (void) -{ - fsi(f); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ - x.fsi(f); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ - fsi(cf); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than complex due to prototype" } */ - x.fsi(cf); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than complex due to prototype" } */ - fcf(f); /* { dg-warning "warning: passing argument 1 of 'fcf' as complex rather than floating due to prototype" } */ - x.fcf(f); /* { dg-warning "warning: passing argument 1 of 'x.fcf' as complex rather than floating due to prototype" } */ - fcf(si); /* { dg-warning "warning: passing argument 1 of 'fcf' as complex rather than integer due to prototype" } */ - x.fcf(si); /* { dg-warning "warning: passing argument 1 of 'x.fcf' as complex rather than integer due to prototype" } */ - ff(sc); /* { dg-warning "warning: passing argument 1 of 'ff' as floating rather than integer due to prototype" } */ - x.ff(sc); /* { dg-warning "warning: passing argument 1 of 'x.ff' as floating rather than integer due to prototype" } */ - ff(cf); /* { dg-warning "warning: passing argument 1 of 'ff' as floating rather than complex due to prototype" } */ - x.ff(cf); /* { dg-warning "warning: passing argument 1 of 'x.ff' as floating rather than complex due to prototype" } */ - ff(1.0); /* { dg-warning "warning: passing argument 1 of 'ff' as 'float' rather than 'double' due to prototype" } */ - x.ff(1.0); /* { dg-warning "warning: passing argument 1 of 'x.ff' as 'float' rather than 'double' due to prototype" } */ - fsll(sc); /* { dg-warning "warning: passing argument 1 of 'fsll' with different width due to prototype" } */ - x.fsll(sc); /* { dg-warning "warning: passing argument 1 of 'x.fsll' with different width due to prototype" } */ - fsc(sll); /* { dg-warning "warning: passing argument 1 of 'fsc' with different width due to prototype" } */ - x.fsc(sll); /* { dg-warning "warning: passing argument 1 of 'x.fsc' with different width due to prototype" } */ - fsi(ui); /* { dg-warning "warning: passing argument 1 of 'fsi' as signed due to prototype" } */ - x.fsi(ui); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as signed due to prototype" } */ - full(sll); /* { dg-warning "warning: passing argument 1 of 'full' as unsigned due to prototype" } */ - x.full(sll); /* { dg-warning "warning: passing argument 1 of 'x.full' as unsigned due to prototype" } */ -} diff --git a/gcc/testsuite/gcc.dg/Wconversion-negative-constants.c b/gcc/testsuite/gcc.dg/Wconversion-negative-constants.c new file mode 100644 index 0000000..80ef410 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wconversion-negative-constants.c @@ -0,0 +1,54 @@ +/* Test for diagnostics for negative constants converted to unsigned types. + These tests come from gcc/testsuite/gcc.dg/overflow-warn-2.c */ + +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Wconversion" } */ + +#include + +void fuc (unsigned char); + +void hc (int x) +{ + unsigned char uc; + + fuc (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + uc = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + uc = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + uc = x ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + uc = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + + fuc('A'); + uc = 'A'; + + uc = x ? 1 : -1; + + uc = x ? SCHAR_MIN : 1; +} + +unsigned fui (unsigned int ui); + +void hi (int x) +{ + unsigned ui; + + fui (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + ui = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + ui = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + ui = x ? INT_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + ui = 1U * -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + ui = ui + INT_MIN; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + + ui = -1 * (1 * -1); + ui = (unsigned) -1; + + ui = x ? 1 : -1; + + ui = x ? INT_MIN : 1; + + ui = ui ? SCHAR_MIN : 1; +} + + +unsigned fui(unsigned a) { return a + -1; } /* { dg-warning "negative integer implicitly converted to unsigned type" } */ diff --git a/gcc/testsuite/gcc.dg/Wconversion.c b/gcc/testsuite/gcc.dg/Wconversion.c deleted file mode 100644 index 7cbcb6a..0000000 --- a/gcc/testsuite/gcc.dg/Wconversion.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Source: PR 137. - - We would not warn about passing an enum, but would warn about - passing a enum that was part of an array. TYPE_MAIN_VARIANT was - not used in the appropriate place in the warning code. */ - -/* { dg-do compile } */ -/* { dg-options -Wconversion } */ - -typedef enum { a } __attribute__((packed)) t; -void f(t x) {} - -int main(void) -{ - t x[2], y; - f(x[0]); /* { dg-bogus "different width" } */ - f(y); /* { dg-bogus "different width" } */ - return 0; -} - diff --git a/gcc/testsuite/gcc.dg/Wtraditional-conversion-2.c b/gcc/testsuite/gcc.dg/Wtraditional-conversion-2.c new file mode 100644 index 0000000..60f0f64 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wtraditional-conversion-2.c @@ -0,0 +1,64 @@ +/* Test messages for -Wtraditional-conversion, including that they are not + pedwarns. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors -Wtraditional-conversion" } */ + +void fsc(signed char); +void fsi(signed int); +void fsll(signed long long); +void fuc(unsigned char); +void fui(unsigned int); +void full(unsigned long long); +void ff(float); +void fld(long double); +void fcf(_Complex float); + +struct s { + void (*fsc)(signed char); + void (*fsi)(signed int); + void (*fsll)(signed long long); + void (*fuc)(unsigned char); + void (*fui)(unsigned int); + void (*full)(unsigned long long); + void (*ff)(float); + void (*fld)(long double); + void (*fcf)(_Complex float); +} x; + +signed char sc; +signed int si; +signed long long sll; +unsigned char uc; +unsigned int ui; +unsigned long long ull; +float f; +long double ld; +_Complex float cf; + +void +g (void) +{ + fsi(f); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ + x.fsi(f); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ + fsi(cf); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than complex due to prototype" } */ + x.fsi(cf); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than complex due to prototype" } */ + fcf(f); /* { dg-warning "warning: passing argument 1 of 'fcf' as complex rather than floating due to prototype" } */ + x.fcf(f); /* { dg-warning "warning: passing argument 1 of 'x.fcf' as complex rather than floating due to prototype" } */ + fcf(si); /* { dg-warning "warning: passing argument 1 of 'fcf' as complex rather than integer due to prototype" } */ + x.fcf(si); /* { dg-warning "warning: passing argument 1 of 'x.fcf' as complex rather than integer due to prototype" } */ + ff(sc); /* { dg-warning "warning: passing argument 1 of 'ff' as floating rather than integer due to prototype" } */ + x.ff(sc); /* { dg-warning "warning: passing argument 1 of 'x.ff' as floating rather than integer due to prototype" } */ + ff(cf); /* { dg-warning "warning: passing argument 1 of 'ff' as floating rather than complex due to prototype" } */ + x.ff(cf); /* { dg-warning "warning: passing argument 1 of 'x.ff' as floating rather than complex due to prototype" } */ + ff(1.0); /* { dg-warning "warning: passing argument 1 of 'ff' as 'float' rather than 'double' due to prototype" } */ + x.ff(1.0); /* { dg-warning "warning: passing argument 1 of 'x.ff' as 'float' rather than 'double' due to prototype" } */ + fsll(sc); /* { dg-warning "warning: passing argument 1 of 'fsll' with different width due to prototype" } */ + x.fsll(sc); /* { dg-warning "warning: passing argument 1 of 'x.fsll' with different width due to prototype" } */ + fsc(sll); /* { dg-warning "warning: passing argument 1 of 'fsc' with different width due to prototype" } */ + x.fsc(sll); /* { dg-warning "warning: passing argument 1 of 'x.fsc' with different width due to prototype" } */ + fsi(ui); /* { dg-warning "warning: passing argument 1 of 'fsi' as signed due to prototype" } */ + x.fsi(ui); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as signed due to prototype" } */ + full(sll); /* { dg-warning "warning: passing argument 1 of 'full' as unsigned due to prototype" } */ + x.full(sll); /* { dg-warning "warning: passing argument 1 of 'x.full' as unsigned due to prototype" } */ +} diff --git a/gcc/testsuite/gcc.dg/Wtraditional-conversion.c b/gcc/testsuite/gcc.dg/Wtraditional-conversion.c new file mode 100644 index 0000000..a3f04ac --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wtraditional-conversion.c @@ -0,0 +1,20 @@ +/* Source: PR 137. + + We would not warn about passing an enum, but would warn about + passing a enum that was part of an array. TYPE_MAIN_VARIANT was + not used in the appropriate place in the warning code. */ + +/* { dg-do compile } */ +/* { dg-options -Wtraditional-conversion } */ + +typedef enum { a } __attribute__((packed)) t; +void f(t x) {} + +int main(void) +{ + t x[2], y; + f(x[0]); /* { dg-bogus "different width" } */ + f(y); /* { dg-bogus "different width" } */ + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/builtin-protos-1.c b/gcc/testsuite/gcc.dg/builtin-protos-1.c index c3cdc53..85f96cf 100644 --- a/gcc/testsuite/gcc.dg/builtin-protos-1.c +++ b/gcc/testsuite/gcc.dg/builtin-protos-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options -Wconversion } */ +/* { dg-options -Wtraditional-conversion } */ int test_s (signed int x) diff --git a/gcc/testsuite/gcc.dg/dfp/Wconversion-2.c b/gcc/testsuite/gcc.dg/dfp/Wconversion-2.c deleted file mode 100644 index afc0b4d..0000000 --- a/gcc/testsuite/gcc.dg/dfp/Wconversion-2.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Test messages for -Wconversion (based on gcc.dg/Wconversion-2.c). */ -/* { dg-do compile } */ -/* { dg-options "-std=gnu99 -Wconversion" } */ - -void fsi(signed int); -void fd32(_Decimal32); -void fd64(_Decimal64); -void fd128(_Decimal128); - -struct s { - void (*fsi)(signed int); - void (*fd32)(_Decimal32); - void (*fd64)(_Decimal64); - void (*fd128)(_Decimal128); -} x; - -signed int si; -unsigned int ui; -_Decimal32 d32; -_Decimal64 d64; -_Decimal128 d128; - -void -g (void) -{ - fsi(d32); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ - x.fsi(d32); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ - fsi(d64); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ - x.fsi(d64); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ - fsi(d128); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ - x.fsi(d128); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ - fd32(si); /* { dg-warning "warning: passing argument 1 of 'fd32' as floating rather than integer due to prototype" } */ - x.fd32(si); /* { dg-warning "warning: passing argument 1 of 'x.fd32' as floating rather than integer due to prototype" } */ - fd64(ui); /* { dg-warning "warning: passing argument 1 of 'fd64' as floating rather than integer due to prototype" } */ - x.fd64(ui); /* { dg-warning "warning: passing argument 1 of 'x.fd64' as floating rather than integer due to prototype" } */ - fd128(si); /* { dg-warning "warning: passing argument 1 of 'fd128' as floating rather than integer due to prototype" } */ - x.fd128(ui); /* { dg-warning "warning: passing argument 1 of 'x.fd128' as floating rather than integer due to prototype" } */ - fd32(1.0); /* { dg-warning "warning: passing argument 1 of 'fd32' as '_Decimal32' rather than 'double' due to prototype" } */ - x.fd32(1.0); /* { dg-warning "warning: passing argument 1 of 'x.fd32' as '_Decimal32' rather than 'double' due to prototype" } */ - fd64(1.0); /* { dg-warning "warning: passing argument 1 of 'fd64' as '_Decimal64' rather than 'double' due to prototype" } */ - x.fd64(1.0); /* { dg-warning "warning: passing argument 1 of 'x.fd64' as '_Decimal64' rather than 'double' due to prototype" } */ - fd128(1.0); /* { dg-warning "warning: passing argument 1 of 'fd128' as '_Decimal128' rather than 'double' due to prototype" } */ - x.fd128(1.0); /* { dg-warning "warning: passing argument 1 of 'x.fd128' as '_Decimal128' rather than 'double' due to prototype" } */ -} diff --git a/gcc/testsuite/gcc.dg/dfp/Wtraditional-conversion-2.c b/gcc/testsuite/gcc.dg/dfp/Wtraditional-conversion-2.c new file mode 100644 index 0000000..b5738c9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/Wtraditional-conversion-2.c @@ -0,0 +1,46 @@ +/* Test messages for -Wtraditional-conversion + (based on gcc.dg/Wtraditional-conversion-2.c). */ + +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wtraditional-conversion" } */ + +void fsi(signed int); +void fd32(_Decimal32); +void fd64(_Decimal64); +void fd128(_Decimal128); + +struct s { + void (*fsi)(signed int); + void (*fd32)(_Decimal32); + void (*fd64)(_Decimal64); + void (*fd128)(_Decimal128); +} x; + +signed int si; +unsigned int ui; +_Decimal32 d32; +_Decimal64 d64; +_Decimal128 d128; + +void +g (void) +{ + fsi(d32); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ + x.fsi(d32); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ + fsi(d64); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ + x.fsi(d64); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ + fsi(d128); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ + x.fsi(d128); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ + fd32(si); /* { dg-warning "warning: passing argument 1 of 'fd32' as floating rather than integer due to prototype" } */ + x.fd32(si); /* { dg-warning "warning: passing argument 1 of 'x.fd32' as floating rather than integer due to prototype" } */ + fd64(ui); /* { dg-warning "warning: passing argument 1 of 'fd64' as floating rather than integer due to prototype" } */ + x.fd64(ui); /* { dg-warning "warning: passing argument 1 of 'x.fd64' as floating rather than integer due to prototype" } */ + fd128(si); /* { dg-warning "warning: passing argument 1 of 'fd128' as floating rather than integer due to prototype" } */ + x.fd128(ui); /* { dg-warning "warning: passing argument 1 of 'x.fd128' as floating rather than integer due to prototype" } */ + fd32(1.0); /* { dg-warning "warning: passing argument 1 of 'fd32' as '_Decimal32' rather than 'double' due to prototype" } */ + x.fd32(1.0); /* { dg-warning "warning: passing argument 1 of 'x.fd32' as '_Decimal32' rather than 'double' due to prototype" } */ + fd64(1.0); /* { dg-warning "warning: passing argument 1 of 'fd64' as '_Decimal64' rather than 'double' due to prototype" } */ + x.fd64(1.0); /* { dg-warning "warning: passing argument 1 of 'x.fd64' as '_Decimal64' rather than 'double' due to prototype" } */ + fd128(1.0); /* { dg-warning "warning: passing argument 1 of 'fd128' as '_Decimal128' rather than 'double' due to prototype" } */ + x.fd128(1.0); /* { dg-warning "warning: passing argument 1 of 'x.fd128' as '_Decimal128' rather than 'double' due to prototype" } */ +} diff --git a/gcc/testsuite/gcc.dg/overflow-warn-2.c b/gcc/testsuite/gcc.dg/overflow-warn-2.c index 189f727..3fa75b6 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-2.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-2.c @@ -1,7 +1,7 @@ -/* Test for diagnostics for constant overflow. Test with -Wconversion. */ +/* Test for diagnostics for constant overflow. Test with -Wtraditional-conversion. */ /* Origin: Joseph Myers */ /* { dg-do compile } */ -/* { dg-options "-std=c99 -Wconversion" } */ +/* { dg-options "-std=c99 -Wtraditional-conversion" } */ #include @@ -82,23 +82,23 @@ void h2 (void) { fsc (SCHAR_MAX + 1); - /* { dg-warning "warning: passing argument 1 of 'fsc' with different width due to prototype" "-Wconversion" { target *-*-* } 84 } */ + /* { dg-warning "warning: passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 84 } */ fsc (SCHAR_MIN - 1); /* { dg-warning "warning: overflow in implicit constant conversion" } */ - /* { dg-warning "warning: passing argument 1 of 'fsc' with different width due to prototype" "-Wconversion" { target *-*-* } 86 } */ + /* { dg-warning "warning: passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 86 } */ fsc (UCHAR_MAX); - /* { dg-warning "warning: passing argument 1 of 'fsc' with different width due to prototype" "-Wconversion" { target *-*-* } 88 } */ + /* { dg-warning "warning: passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 88 } */ fsc (UCHAR_MAX + 1); /* { dg-warning "warning: overflow in implicit constant conversion" } */ - /* { dg-warning "warning: passing argument 1 of 'fsc' with different width due to prototype" "-Wconversion" { target *-*-* } 90 } */ - fuc (-1); /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ - /* { dg-warning "warning: passing argument 1 of 'fuc' with different width due to prototype" "-Wconversion" { target *-*-* } 92 } */ + /* { dg-warning "warning: passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 90 } */ + fuc (-1); + /* { dg-warning "warning: passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 92 } */ fuc (UCHAR_MAX + 1); /* { dg-warning "warning: large integer implicitly truncated to unsigned type" } */ - /* { dg-warning "warning: passing argument 1 of 'fuc' with different width due to prototype" "-Wconversion" { target *-*-* } 94 } */ - fuc (SCHAR_MIN); /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ - /* { dg-warning "warning: passing argument 1 of 'fuc' with different width due to prototype" "-Wconversion" { target *-*-* } 96 } */ + /* { dg-warning "warning: passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 94 } */ + fuc (SCHAR_MIN); + /* { dg-warning "warning: passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 96 } */ fuc (SCHAR_MIN - 1); /* { dg-warning "warning: large integer implicitly truncated to unsigned type" } */ - /* { dg-warning "warning: passing argument 1 of 'fuc' with different width due to prototype" "-Wconversion" { target *-*-* } 98 } */ + /* { dg-warning "warning: passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 98 } */ fuc (-UCHAR_MAX); /* { dg-warning "warning: large integer implicitly truncated to unsigned type" } */ - /* { dg-warning "warning: passing argument 1 of 'fuc' with different width due to prototype" "-Wconversion" { target *-*-* } 100 } */ + /* { dg-warning "warning: passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 100 } */ } void fui (unsigned int); @@ -111,7 +111,7 @@ void h2i (int x) { /* For some reason, we only give certain warnings for implicit - conversions among values of the same precision with -Wconversion, + conversions among values of the same precision with -Wtraditional-conversion, while we don't give others at all. */ fsi ((unsigned)INT_MAX + 1); /* { dg-warning "warning: passing argument 1 of 'fsi' as signed due to prototype" } */ si = (unsigned)INT_MAX + 1; @@ -121,12 +121,12 @@ h2i (int x) si = x ? (unsigned)INT_MAX + 2 : 1; fsi (UINT_MAX); /* { dg-warning "warning: passing argument 1 of 'fsi' as signed due to prototype" } */ si = UINT_MAX; - fui (-1); /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ - /* { dg-warning "warning: passing argument 1 of 'fui' as unsigned due to prototype" "-Wconversion" { target *-*-* } 124 } */ - ui = -1; /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ - ui = x ? -1 : 1U; /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ - fui (INT_MIN); /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ - /* { dg-warning "warning: passing argument 1 of 'fui' as unsigned due to prototype" "-Wconversion" { target *-*-* } 128 } */ - ui = INT_MIN; /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ - ui = x ? INT_MIN : 1U; /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ + fui (-1); + /* { dg-warning "warning: passing argument 1 of 'fui' as unsigned due to prototype" "-Wtraditional-conversion" { target *-*-* } 124 } */ + ui = -1; + ui = x ? -1 : 1U; + fui (INT_MIN); + /* { dg-warning "warning: passing argument 1 of 'fui' as unsigned due to prototype" "-Wtraditional-conversion" { target *-*-* } 128 } */ + ui = INT_MIN; + ui = x ? INT_MIN : 1U; } -- cgit v1.1