PR testsuite/88098 - FAIL: gcc.dg/Wbuiltin-declaration-mismatch-4.c
gcc/c/ChangeLog: PR testsuite/88098 * c-typeck.c (convert_arguments): Call builtin_decl_explicit instead. (maybe_warn_builtin_no_proto_arg): Handle short enum to int promotion. gcc/testsuite/ChangeLog: PR testsuite/88098 * gcc.dg/Wbuiltin-declaration-mismatch-4.c: Adjust. * gcc.dg/Wbuiltin-declaration-mismatch-5.c: New test. * gcc.dg/torture/pr67222.c: Adjust. From-SVN: r266417
This commit is contained in:
parent
e987fb1ebe
commit
db1d09b049
6 changed files with 50 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
2018-11-23 Martin Sebor <msebor@redhat.com>
|
||||
|
||||
PR testsuite/88098
|
||||
* c-typeck.c (convert_arguments): Call builtin_decl_explicit instead.
|
||||
(maybe_warn_builtin_no_proto_arg): Handle short enum to int promotion.
|
||||
|
||||
2018-11-20 Martin Sebor <msebor@redhat.com>
|
||||
|
||||
* c-parser.c (c_parser_has_attribute_expression): New function.
|
||||
|
|
|
@ -3422,7 +3422,10 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
|
|||
built_in_function code = DECL_FUNCTION_CODE (fundecl);
|
||||
if (C_DECL_BUILTIN_PROTOTYPE (fundecl))
|
||||
{
|
||||
if (tree bdecl = builtin_decl_implicit (code))
|
||||
/* For a call to a built-in function declared without a prototype
|
||||
use the types of the parameters of the internal built-in to
|
||||
match those of the arguments to. */
|
||||
if (tree bdecl = builtin_decl_explicit (code))
|
||||
builtin_typelist = TYPE_ARG_TYPES (TREE_TYPE (bdecl));
|
||||
}
|
||||
|
||||
|
@ -6461,7 +6464,9 @@ maybe_warn_builtin_no_proto_arg (location_t loc, tree fundecl, int parmnum,
|
|||
&& TYPE_MODE (parmtype) == TYPE_MODE (argtype))
|
||||
return;
|
||||
|
||||
if (parmcode == argcode
|
||||
if ((parmcode == argcode
|
||||
|| (parmcode == INTEGER_TYPE
|
||||
&& argcode == ENUMERAL_TYPE))
|
||||
&& TYPE_MAIN_VARIANT (parmtype) == TYPE_MAIN_VARIANT (promoted))
|
||||
return;
|
||||
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2018-11-23 Martin Sebor <msebor@redhat.com>
|
||||
|
||||
PR testsuite/88098
|
||||
* gcc.dg/Wbuiltin-declaration-mismatch-4.c: Adjust.
|
||||
* gcc.dg/Wbuiltin-declaration-mismatch-5.c: New test.
|
||||
* gcc.dg/torture/pr67222.c: Adjust.
|
||||
|
||||
2018-11-23 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/88149
|
||||
|
|
|
@ -77,9 +77,9 @@ void test_integer_conversion_memset (void *d)
|
|||
/* Passing a ptrdiff_t where size_t is expected may not be unsafe
|
||||
but because GCC may emits suboptimal code for such calls warning
|
||||
for them helps improve efficiency. */
|
||||
memset (d, 0, diffi); /* { dg-warning ".memset. argument 3 promotes to .ptrdiff_t. {aka .long int.} where .long unsigned int. is expected" } */
|
||||
memset (d, 0, diffi); /* { dg-warning ".memset. argument 3 promotes to .ptrdiff_t. {aka .\(long \)?int.} where .\(long \)?unsigned int. is expected" } */
|
||||
|
||||
memset (d, 0, 2.0); /* { dg-warning ".memset. argument 3 type is .double. where 'long unsigned int' is expected" } */
|
||||
memset (d, 0, 2.0); /* { dg-warning ".memset. argument 3 type is .double. where '\(long \)?unsigned int' is expected" } */
|
||||
|
||||
/* Verify that the same call as above but to the built-in doesn't
|
||||
trigger a warning. */
|
||||
|
@ -108,7 +108,8 @@ void test_real_conversion_fabs (void)
|
|||
/* In C, the type of an enumeration constant is int. */
|
||||
d = fabs (e0); /* { dg-warning ".fabs. argument 1 type is .int. where .double. is expected in a call to built-in function declared without prototype" } */
|
||||
|
||||
d = fabs (e); /* { dg-warning ".fabs. argument 1 type is .enum E. where .double. is expected in a call to built-in function declared without prototype" } */
|
||||
d = fabs (e); /* { dg-warning ".fabs. argument 1 type is .enum E. where .double. is expected in a call to built-in function declared without prototype" "ordinary enum" { target { ! short_enums } } } */
|
||||
/* { dg-warning ".fabs. argument 1 promotes to .int. where .double. is expected in a call to built-in function declared without prototype" "size 1 enum" { target short_enums } .-1 } */
|
||||
|
||||
/* No warning here since float is promoted to double. */
|
||||
d = fabs (f);
|
||||
|
|
19
gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-5.c
Normal file
19
gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-5.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* PR testsuite/88098 - FAIL: gcc.dg/Wbuiltin-declaration-mismatch-4.c
|
||||
{ dg-do compile }
|
||||
{ dg-options "-Wbuiltin-declaration-mismatch -fshort-enums" } */
|
||||
|
||||
int abs ();
|
||||
double fabs (); /* { dg-message "built-in .fabs. declared here" } */
|
||||
|
||||
enum E { e0 } e;
|
||||
|
||||
int i;
|
||||
double d;
|
||||
|
||||
void test_short_enums (void)
|
||||
{
|
||||
/* enum e promotes to int. */
|
||||
i = abs (e);
|
||||
|
||||
d = fabs (e); /* { dg-warning ".fabs. argument 1 promotes to .int. where .double. is expected in a call to built-in function declared without prototype" } */
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* PR middle-end/67222 */
|
||||
/* PR middle-end/67222 - ICE in gimple_call_arg with bogus posix_memalign */
|
||||
/* { dg-do compile } */
|
||||
|
||||
void
|
||||
|
@ -17,3 +17,9 @@ foo (void **p)
|
|||
posix_memalign (p, "qui", 3);
|
||||
posix_memalign (p, 1, 2);
|
||||
}
|
||||
|
||||
/* Prune warnings:
|
||||
{ dg-prune-output "call to built-in function declared without prototype" }
|
||||
{ dg-prune-output "too few arguments to built-in function" }
|
||||
{ dg-prune-output "incompatible pointer type" }
|
||||
{ dg-prune-output "\\\[-Wint-conversion]" } */
|
||||
|
|
Loading…
Add table
Reference in a new issue