[Bug c/41789] New: -Wmissing prototypes: nested functions shouldn't produce warnings if defined before first use

2009-10-21 Thread gcczilla1 at achurch dot org
Currently, if one compiles with -Wmissing-prototypes, GCC will complain about a
nested function defined with no preceding prototype declaration, for example:

int foo(int a) {
auto int bar(int b) { return b; }
return bar(a);
}

According to bug 19635 comment #1, the "proper" way to do this is to explicitly
add a forward declaration:

int foo(int a) {
auto int bar(int b);
auto int bar(int b) { return b; }
return bar(a);
}

But this seems redundant to me, since the declaration is local to the enclosing
function and there's no danger of any external code calling the nested function
improperly.  Would it be possible to have GCC treat nested functions like
file-scope static functions, and omit the missing prototype warning if the
function is properly defined (with auto) before its first use?


-- 
   Summary: -Wmissing prototypes: nested functions shouldn't produce
warnings if defined before first use
   Product: gcc
   Version: 4.4.2
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcczilla1 at achurch dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41789



[Bug c/41789] -Wmissing prototypes: nested functions shouldn't produce warnings if defined before first use

2009-10-21 Thread gcczilla1 at achurch dot org


--- Comment #2 from gcczilla1 at achurch dot org  2009-10-22 06:57 ---
Sorry!  Not sure how I missed that one in my search.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41789



[Bug c/44502] New: Bogus diagnostic: format '%u' expects type 'unsigned int', but argument 2 has type 'unsigned int'

2010-06-11 Thread gcczilla1 at achurch dot org
When passing the result of __builtin_bswap32() to printf() and -Wformat is
enabled, the following code:

#include 
int foo(unsigned int arg) {
return printf("%u", __builtin_bswap32(arg));
}

generates this odd diagnostic:

foo.c:3: warning: format '%u' expects type 'unsigned int', but argument 2 has
type 'unsigned int'

Strangely enough, if I use "%d" instead of "%u", no diagnostic is generated.

I haven't checked the details of __builtin_bswap32()'s implementation, but I
wonder if this might be the same issue as (or related to) bug 21962?


-- 
   Summary: Bogus diagnostic: format '%u' expects type 'unsigned
int', but argument 2 has type 'unsigned int'
   Product: gcc
   Version: 4.4.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
     Component: c
    AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcczilla1 at achurch dot org
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44502