This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/15052] gcc frontend accepts mismatched function declaration/defintion
- From: "tjruwase at stanfordalumni dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Apr 2004 00:00:58 -0000
- Subject: [Bug c/15052] gcc frontend accepts mismatched function declaration/defintion
- References: <20040421182423.15052.tjruwase@stanfordalumni.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From tjruwase at stanfordalumni dot org 2004-04-22 00:00 -------
Is this consistent considering that the front end rejects the following
int const foo();
int foo();
In addition, despite the warning message of the qualifier being ignored, the
return type is still augmented with the qualifier by the line
type = c_build_qualified_type (type, type_quals);
which comes right after the warning in the excerpt of c-decl.c below
I m not sure what the right thing is, but this seems inconsistent to me.
if (type_quals)
{
/* Type qualifiers on a function return type are normally
permitted by the standard but have no effect, so give a
warning at -W. Qualifiers on a void return type have
meaning as a GNU extension, and are banned on function
definitions in ISO C. FIXME: strictly we shouldn't
pedwarn for qualified void return types except on function
definitions, but not doing so could lead to the undesirable
state of a "volatile void" function return type not being
warned about, and a use of the function being compiled
with GNU semantics, with no diagnostics under -pedantic. */
if (VOID_TYPE_P (type) && pedantic && !in_system_header)
pedwarn ("ISO C forbids qualified void function return type");
else if (extra_warnings
&& !(VOID_TYPE_P (type)
&& type_quals == TYPE_QUAL_VOLATILE))
warning ("type qualifiers ignored on function return type");
type = c_build_qualified_type (type, type_quals);
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15052