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

Reply via email to