+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.
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));
}
&& 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;
+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
/* 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. */
/* 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);
--- /dev/null
+/* 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" } */
+}
-/* PR middle-end/67222 */
+/* PR middle-end/67222 - ICE in gimple_call_arg with bogus posix_memalign */
/* { dg-do compile } */
void
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]" } */