From: <dan...@ya...> - 2001-09-05 03:02:34
|
--- Danny Smith <dan...@ya...> wrote: > Date: Wed, 5 Sep 2001 12:08:19 +1000 (EST) > From: Danny Smith <dan...@ya...> > Subject: [Refresh]: patch for C++ parser bug with function attributes > To: GCC Patches <gcc...@gc...> > > > This refreshes Bob Wilson's patch > http://gcc.gnu.org/ml/gcc-patches/2001-01/msg01751.html > which I quote: > > <begin quote> > > The attached GCC patch fixes a previously reported problem with > function > attributes (see > http://gcc.gnu.org/ml/gcc-bugs/1999-07/msg00835.html). > > <snip> > > Whether you use my patch or someone else's, please fix this! This > bug > is rather serious in the Mingw environment where the standard header > files declare lots of functions with attributes. > > <snip> > > This patch fixes a bug in the C++ front end that causes attributes, > such as "stdcall" in the Mingw environment, to be added onto existing > type nodes instead of creating new type variants. One symptom of > this > is that STL breaks in the Mingw environment if a file includes > <windows.h>. > > <end quote> > > > Bob Wilson's patch has been incorporated into gcc-2.95.3 for cygwin > and > mingw "special" releases for several months and corrects the problem. > > However, the bug has recently been reported on Cygwin mailing list > for > a > GCC-3.0 build ( http://www.cygwin.com/ml/cygwin/2001-09/msg00045.html > ). > > The following is relative to gcc-3.0.1 (release). After a bootstrap > build of 3.0.1 with this patch, Mumit Khan's testcase referred to > above > and the example reported to Cygwin list compile and execute correctly > on mingw. > > Please apply to branch. > > 2001-09-05 Bob Wilson <bwilson at tensilica dot com> > > * decl.c (grokdeclarator): Create a new variant of type before > passing inner_attrs to decl_attributes. > > --- gcc-3.0.1/gcc/cp/decl.c Tue Sep 04 19:29:10 2001 > +++ decl.c Tue Sep 04 19:38:45 2001 > @@ -10469,7 +10469,16 @@ grokdeclarator (declarator, declspecs, d > ignore_attrs = 0; > else if (inner_attrs) > { > - decl_attributes (type, inner_attrs, NULL_TREE); > + /* Create a dummy decl to pass to decl_attributes. The > + attributes will be added to a variant of type, and this > + new variant type can be retrieved from the dummy decl. > + Passing type directly causes the attributes to be added > + to type, which is wrong because type may be used > + elsewhere without attributes. */ > + > + tree dummy = build_decl (TYPE_DECL, NULL_TREE, type); > + decl_attributes (dummy, inner_attrs, NULL_TREE); > + type = TREE_TYPE (dummy); > inner_attrs = NULL_TREE; > } > > @@ -10988,7 +10997,18 @@ grokdeclarator (declarator, declspecs, d > if (inner_attrs) > { > if (! ignore_attrs) > - decl_attributes (type, inner_attrs, NULL_TREE); > + { > + /* Create a dummy decl to pass to decl_attributes. The > + attributes will be added to a variant of type, and this > + new variant type can be retrieved from the dummy decl. > + Passing type directly causes the attributes to be added > + to type, which is wrong because type may be used > + elsewhere without attributes. */ > + > + tree dummy = build_decl (TYPE_DECL, NULL_TREE, type); > + decl_attributes (dummy, inner_attrs, NULL_TREE); > + type = TREE_TYPE (dummy); > + } > else if (attrlist) > TREE_VALUE (attrlist) = chainon (inner_attrs, TREE_VALUE > (attrlist)); > else > > > > > http://travel.yahoo.com.au - Yahoo! Travel > - Got Itchy feet? Get inspired! > http://travel.yahoo.com.au - Yahoo! Travel - Got Itchy feet? Get inspired! |