C++ PATCH to attribute handling

Danny Smith danny_r_smith_2001@yahoo.co.nz
Fri Feb 8 19:57:00 GMT 2002


 
This change
cp/Changelog
2002-01-31  Jason Merrill  <jason@redhat.com>

	Allow attributes in parms and casts.
	* parse.y (named_parm): Don't strip attrs.
	(declmods): Remove 'attributes' production.
	(nonempty_cv_qualifiers): Accept attributes.
	(ATTRIBUTE): Give precedence.
	* decl.c (groktypename): Handle attributes.
	(grokparms): Likewise.


causes a regression in handling of attributes in C++ on mingw and cygwin.

Prior to this patch all six declarations below were accepted and did
the right thing in both C and C++.  With the patch, the last of the six
declarations below

__attribute__((dllexport))
int
__attribute__((stdcall)) // parse error before '__attribute__' in C++
six (void);

causes a parse error in C++ (only)

Unfortunately, the sixth form is probably the one most widely used
in the windows' world and the difference in behaviour between C and C++
is likely to cause problems amongst cygwin and mingw users.

The post to GCC-patches mentions that this is a "quick hack" until parser
is overhauled. A "quick local unhack"  makes G++ 3.1 friendlier for windows
users.  Is the real fix likely to accept the form above?


/* foo.C */

int
__attribute__((dllexport))
__attribute__((stdcall))
one(void); // OK 

__attribute__((dllexport))
__attribute__((stdcall))
int
two(void); // OK

int
__attribute__((stdcall))
three (void)
__attribute__((dllexport)); // OK

__attribute__((stdcall))
int
four (void)
__attribute__((dllexport)); // OK

int
five(void)
__attribute__((dllexport))
__attribute__((stdcall));  // OK

__attribute__((dllexport))
int
__attribute__((stdcall)) // parse error before '__attribute__' in C++
six (void);              // OK in C



http://greetings.yahoo.com.au - Yahoo! Greetings
- Send your Valentines love online.



More information about the Gcc-patches mailing list