RFC/RFHelp: c-decl.c rewrite - almost but not quite
Zack Weinberg
zack@codesourcery.com
Tue Mar 16 23:42:00 GMT 2004
"Joseph S. Myers" <jsm@polyomino.org.uk> writes:
> On Tue, 16 Mar 2004, Zack Weinberg wrote:
>
>> + warning ("its scope is only this definition or declaration,"
>> + " which is probably not what you want");
>
> Should be inform ().
Preexisting condition.
>> -void bar2 () {} /* { dg-warning "old-style parameter declaration" } */
>> +void bar2 () {} /* { dg-bogus "old-style function definition" } */
>
> I don't see how this warning is bogus. The intention of
> -Wold-style-definition, which this testcase tests, is to warn for *all*
> old-style definitions, even if there is a prior prototype. In particular,
> it should warn when () is used instead of (void).
C99 6.7.5.3p14:
An identifier list declares only the identifiers of the parameters
of the function. An empty list in a function declarator that is
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
part of a definition of that function specifies that the function
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has no parameters. The empty list in a function declarator that is
^^^^^^^^^^^^^^^^^^
not part of a definition of that function specifies that no
information about the number or types of the parameters is
supplied.
I read this to indicate that *in a function definition* () is the same
as (void), and should not be taken as an old-style definition.
zw
More information about the Gcc-patches
mailing list