This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Emit warning for function declaration with qualifiedvoid return type
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Devang Patel <dpatel at apple dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 4 Jan 2005 19:51:05 +0000 (UTC)
- Subject: Re: [PATCH] Emit warning for function declaration with qualifiedvoid return type
- References: <00999771-5E88-11D9-ABDE-000393A91CAA@apple.com>
On Tue, 4 Jan 2005, Devang Patel wrote:
> This patch enables pedantic warning, in c99 mode, for function declarations
> that has qualified void return type. GCC already emits warning for function
My understanding of the standard is that the constraint in 6.9.1#3 is only
for function definitions, not for function declarations and certainly not
for arbitrary function type declarators. For function type declarators
the constraints are the weaker ones in 220.127.116.11#1. Things are a bit less
clear about declarations of functions which are not definitions, but my
view is that the correct interpretation is that the constraint in the
subclause "Function definitions" should only apply to such definitions.
I haven't yet put this in my list of pre-DRs, but I discussed it with
Derek Jones last month and he agreed with my interpretation.
Interpreting it otherwise would also forbid
struct s f();
// struct s gets defined later before f is defined or called.
which is a natural reason for the constraints on function declarators to
be weaker than those on definitions.
Please note also:
* The same constraint is in C90 6.7.1; there should not be a C99
* The examples in DR#113 (supposing you came across this issue as a
failure in a testsuite referencing that DR) only involve function
definitions; the question of other declarations was not raised there.
> This is a regression from earlier GCC.
This is a deliberate change from earlier GCC.
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
email@example.com (personal mail)
firstname.lastname@example.org (CodeSourcery mail)
email@example.com (Bugzilla assignments and CCs)