On Sat, Jan 26, 2019 at 01:35:05PM +0100, Jakub Jelinek wrote: > On Sat, Jan 26, 2019 at 01:25:04AM +0000, Joseph Myers wrote: > > It's also broken the build of the glibc testsuite, e.g.: > > > > ../time/time.h:88:15: error: mismatch in argument 1 type of built-in > > function 'strftime'; expected 'char *' > > [-Werror=builtin-declaration-mismatch] > > 88 | extern size_t strftime (char *__restrict __s, size_t __maxsize, > > > > (presence or absence of qualifiers on a parameter is not part of the > > function type and should not be compared here). > > There are several further issues, even after fixing the toplevel qualifiers on > arguments as well as return type + fixing up the testcases, there is another > problem, the code has the magic handling only for fileptr_type_node, but we > actually need handling for all builtin_structptr_types struct types, > otherwise e.g. for strftime we warn that the last argument should not be > const struct tm *, but const void *, when it actually should be const struct > tm *.
It is actually worse than that, because unlike C++, in C fileptr_type_node is a mere void * and const_tm_ptr_type_node a mere const_ptr_type_node. So, on /* PR c/86125 */ /* { dg-do compile } */ /* { dg-options "-Wbuiltin-declaration-mismatch -Wextra -Wno-ignored-qualifiers" } */ typedef __SIZE_TYPE__ size_t; struct FILE; struct tm; struct fenv_t; struct fexcept_t; typedef struct FILE FILE; typedef struct fenv_t fenv_t; typedef struct fexcept_t fexcept_t; typedef const int cint; size_t strftime (char *__restrict, const size_t, const char *__restrict, /* { dg-bogus "mismatch in argument 1 type of built-in function" } */ const struct tm *__restrict) __attribute__((nothrow)); int fprintf (struct FILE *, const char *const, ...); /* { dg-bogus "mismatch in argument 2 type of built-in function" } */ cint putc (int, struct FILE *); /* { dg-bogus "mismatch in return type of built-in function" } */ cint fegetenv (fenv_t *); /* { dg-bogus "mismatch in argument 1 type of built-in function" } */ cint fesetenv (const fenv_t *); /* { dg-bogus "mismatch in return type of built-in function" } */ int fegetexceptflag (fexcept_t *, const int); /* { dg-bogus "mismatch in argument 1 type of built-in function" } */ int fesetexceptflag (const fexcept_t *, const int); /* { dg-bogus "mismatch in argument 1 type of built-in function" } */ we get among all the other bogus warnings Wbuiltin-declaration-mismatch-11.c:21:5: warning: mismatch in argument 1 type of built-in function ‘fegetexceptflag’; expected ‘struct FILE *’ [-Wbuiltin-declaration-mismatch] 21 | int fegetexceptflag (fexcept_t *, const int); /* { dg-bogus "mismatch in argument 1 type of built-in function" } */ | ^~~~~~~~~~~~~~~ Suggesting one uses struct FILE * argument to fegetexceptflag is not a very good suggestion. Jakub