This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: (C++) patch for VC++-ish attributes
- To: egcs-patches at cygnus dot com
- Subject: Re: (C++) patch for VC++-ish attributes
- From: Jason Merrill <jason at cygnus dot com>
- Date: 18 Oct 1998 04:12:47 -0700
- References: <199810181010.DAA01032@yorick.cygnus.com>
Just after mailing that, I realized that the binding was wrong, for cases
like
int (__cdecl * __cdecl f ())();
The fix:
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.239
diff -c -p -r1.239 decl.c
*** decl.c 1998/10/18 03:10:42 1.239
--- decl.c 1998/10/18 11:10:27
*************** grokdeclarator (declarator, declspecs, d
*** 8534,8539 ****
--- 8534,8541 ----
tree raises = NULL_TREE;
int template_count = 0;
tree in_namespace = NULL_TREE;
+ tree inner_attrs;
+ int ignore_attrs;
RIDBIT_RESET_ALL (specbits);
if (decl_context == FUNCDEF)
*************** grokdeclarator (declarator, declspecs, d
*** 9389,9394 ****
--- 9391,9399 ----
Descend through it, creating more complex types, until we reach
the declared identifier (or NULL_TREE, in an absolute declarator). */
+ inner_attrs = NULL_TREE;
+ ignore_attrs = 0;
+
while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE
&& TREE_CODE (declarator) != TEMPLATE_ID_EXPR)
{
*************** grokdeclarator (declarator, declspecs, d
*** 9435,9449 ****
quals = NULL_TREE;
}
}
switch (TREE_CODE (declarator))
{
case TREE_LIST:
{
/* We encode a declarator with embedded attributes using
! a TREE_LIST. */
! tree attrs = TREE_PURPOSE (declarator);
declarator = TREE_VALUE (declarator);
- decl_attributes (type, attrs, NULL_TREE);
}
break;
--- 9440,9468 ----
quals = NULL_TREE;
}
}
+
+ /* See the comment for the TREE_LIST case, below. */
+ if (ignore_attrs)
+ ignore_attrs = 0;
+ else if (inner_attrs)
+ {
+ decl_attributes (type, inner_attrs, NULL_TREE);
+ inner_attrs = NULL_TREE;
+ }
+
switch (TREE_CODE (declarator))
{
case TREE_LIST:
{
/* We encode a declarator with embedded attributes using
! a TREE_LIST. The attributes apply to the declarator
! directly inside them, so we have to skip an iteration
! before applying them to the type. If the declarator just
! inside is the declarator-id, we apply the attrs to the
! decl itself. */
! inner_attrs = TREE_PURPOSE (declarator);
! ignore_attrs = 1;
declarator = TREE_VALUE (declarator);
}
break;
*************** grokdeclarator (declarator, declspecs, d
*** 10085,10090 ****
--- 10104,10120 ----
default:
my_friendly_abort (158);
}
+ }
+
+ /* See the comment for the TREE_LIST case, above. */
+ if (inner_attrs)
+ {
+ if (! ignore_attrs)
+ decl_attributes (type, inner_attrs, NULL_TREE);
+ else if (attrlist)
+ TREE_VALUE (attrlist) = chainon (inner_attrs, TREE_VALUE (attrlist));
+ else
+ attrlist = build_decl_list (NULL_TREE, inner_attrs);
}
if (explicitp == 1)