This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Anonymous struct ambiguity detection (PR c/4784)
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 9 May 2010 13:19:34 -0700
- Subject: Re: Anonymous struct ambiguity detection (PR c/4784)
- References: <Pine.LNX.4.64.1005091620080.17242@digraph.polyomino.org.uk>
On Sun, May 9, 2010 at 9:21 AM, Joseph S. Myers <joseph@codesourcery.com> wrote:
> This patch fixes PR 4784, the failure of the C front end to diagnose
> duplicate fields where anonymous structures and unions are involved.
> This is part of implementing C1X requirements for anonymous structures
> and unions ("The members of an anonymous struct or union are
> considered to be members of the containing structure or union.",
> meaning they have the same scope and namespace as members of the
> containing type and so duplicates violate the constraint in 6.7#3 on
> duplicate declarations of an identifier with no linkage).
>
> Bootstrapped with no regressions on x86_64-unknown-linux-gnu. ?Applied
> to mainline.
>
> 2010-05-09 ?Joseph Myers ?<joseph@codesourcery.com>
>
> ? ? ? ?PR c/4784
> ? ? ? ?* c-decl.c (detect_field_duplicates_hash): New. ?Handle anonymous
> ? ? ? ?structures and unions recursively.
> ? ? ? ?(detect_field_duplicates): Move duplicate detection with a hash to
> ? ? ? ?detect_field_duplicates_hash. ?Always use a hash if anonymous
> ? ? ? ?structures or unions are present.
> ? ? ? ?* doc/extend.texi (Unnamed Fields): Document that duplicate fields
> ? ? ? ?give errors.
>
> testsuite:
> 2010-05-09 ?Joseph Myers ?<joseph@codesourcery.com>
>
> ? ? ? ?PR c/4784
> ? ? ? ?* gcc.dg/anon-struct-9.c: New test.
>
This test failed on Linux/ia32.
--
H.J.