This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: fix regression in 4.0
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Dale Johannesen <dalej at apple dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 13 Dec 2004 13:49:56 -0800
- Subject: Re: Patch: fix regression in 4.0
- References: <DC69BDD0-4D4B-11D9-A6AD-000A95D7CD40@apple.com>
At Mon, 13 Dec 2004 13:13:39 -0800,
Dale Johannesen wrote:
>
> As discussed on gcc list, this accepts
> int use() { int foo(); } /* implicit int */
> void foo() {}
> or
> extern void foo();
> with a warning instead of an error, as earlier versions did.
> Testing in progress, OK if it passes?
>
> Please refer to test case. The first patch line causes case 8 to
> get a type mismatch error, not a warning (of course it got another
> error later). The rest causes cases 9 and 10 to be accepted as in
> earlier compilers.
Your diff is incorrectly generated and your mailer mangled it. Please
regenerate it using cvs diff -[cu]p (either -c or -u is acceptable)
and resend as an attachment so it doesn't get mangled. (You appear to
be using Mail.app - give the file a .txt extension so the attachment
is assigned the proper MIME type.)
> Case 5 still behaves differently; it is a warning not an error as in
> earlier
> compilers. This is due to Zack's code
> /* Permit void foo (...) to match int foo (...) if the latter is
> the definition and implicit int was used. See
> c-torture/compile/920625-2.c. */
> However, the example in 920625-2.c is not quite the same, it is
> int use() { extern void foo(); }
> foo() {}
>
> I would not expect that example to get into this code at all, since
> the declarations are not visible in the same scope. But accepting
> that mismatch here means accepting case 5 as well.
We compare the two decls of foo() in 920625-2.c despite their not
being visible in the same scope. There is a mostly-accurate comment
explaining why, in c-decl.c, above the definition of struct c_scope.
Case 5 appears to be
> extern void foo5(); /* { dg-warning "previous declaration" } */
> foo5() {} /* { dg-warning "conflicting types" } */
and I think it's okay for that to be just a warning.
zw