https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79008

            Bug ID: 79008
           Summary: missing detail in -Wbuiltin-declaration-mismatch
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

In C++ (but not in C) -Wbuiltin-declaration-mismatch prints the conflicting
declarations of the function as shown below.  This is helpful when the
declarations visibly differ but not so much when they look the same as is
likely to be common in code that declares the function based on the C or POSIX
standards.

To avoid this problem, when the conflict is due to missing attributes, the
warning should also include the attributes that cause the conflict.

To make this feature generally available beyond this specific warning I would
suggest to enhance the pretty printer to make it possible to also include
attributes in a declaration.  E.g., by interpreting the pound ('#') flag as a
request to do so ("%#qE").

$ cat b.c && gcc -S -Wall -Wextra -Wpedantic -xc++ b.c
extern "C" int sprintf (char*, ...);

b.c:1:16: warning: declaration of ‘int sprintf(char*, ...)’ conflicts with
built-in declaration ‘int sprintf(char*, const char*, ...)’
[-Wbuiltin-declaration-mismatch]
 extern "C" int sprintf (char*, ...);
                ^~~~~~~

Reply via email to