[PATCH] Fix PR c++/35320: ICE with invalid friend declaration

Simon Martin simartin@users.sourceforge.net
Sat Mar 15 13:52:00 GMT 2008


Hi all.

The following invalid snippet triggers an segmentation fault since GCC 3.1:

=== cut here ===
typedef void (func_type)();

struct A
{
        friend func_type f : 2;
};
=== cut here ===

The ICE happens in 'grokbitfield', that calls 'grokdeclarator' with a
null ATTRLIST, that is dereferenced when calling 'do_friend', hence the
segmentation fault.

The attached patch adds an extra argument to 'grokbitfield': the list of
attributes, that is passed to 'grokdeclarator', fixing the segmentation
fault. Moreover, since all the callers of 'grokbitfield' apply the
attributes to the created declaration, I've moved this into
'grokbitfield'... an extra reason to pass it those attributes.

I've successfully regtested this patch on x86_64-apple-darwin-9. Is it
OK for the mainline?

Best regards,
Simon

:ADDPATCH c++:





-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_35320
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080315/738ae06a/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr35320.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080315/738ae06a/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_35320_testsuite
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080315/738ae06a/attachment-0002.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bitfield3.C
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080315/738ae06a/attachment-0003.ksh>


More information about the Gcc-patches mailing list