Commit 1eab9b56 by Jason Merrill Committed by Jason Merrill

decl.c (grokdeclarator): Embedded attrs bind to the right, not the left.

	* decl.c (grokdeclarator): Embedded attrs bind to the right,
	not the left.

From-SVN: r23160
parent 52fbc847
1998-10-18 Jason Merrill <jason@yorick.cygnus.com> 1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
* parse.y (fn.def2): Fix 'attrs' format. * parse.y (fn.def2): Fix 'attrs' format.
1998-10-18 Alastair J. Houghton <ajh8@doc.ic.ac.uk> 1998-10-18 Alastair J. Houghton <ajh8@doc.ic.ac.uk>
......
...@@ -8534,6 +8534,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -8534,6 +8534,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
tree raises = NULL_TREE; tree raises = NULL_TREE;
int template_count = 0; int template_count = 0;
tree in_namespace = NULL_TREE; tree in_namespace = NULL_TREE;
tree inner_attrs;
int ignore_attrs;
RIDBIT_RESET_ALL (specbits); RIDBIT_RESET_ALL (specbits);
if (decl_context == FUNCDEF) if (decl_context == FUNCDEF)
...@@ -9389,6 +9391,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -9389,6 +9391,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
Descend through it, creating more complex types, until we reach Descend through it, creating more complex types, until we reach
the declared identifier (or NULL_TREE, in an absolute declarator). */ the declared identifier (or NULL_TREE, in an absolute declarator). */
inner_attrs = NULL_TREE;
ignore_attrs = 0;
while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE
&& TREE_CODE (declarator) != TEMPLATE_ID_EXPR) && TREE_CODE (declarator) != TEMPLATE_ID_EXPR)
{ {
...@@ -9435,15 +9440,29 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -9435,15 +9440,29 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
quals = NULL_TREE; 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)) switch (TREE_CODE (declarator))
{ {
case TREE_LIST: case TREE_LIST:
{ {
/* We encode a declarator with embedded attributes using /* We encode a declarator with embedded attributes using
a TREE_LIST. */ a TREE_LIST. The attributes apply to the declarator
tree attrs = TREE_PURPOSE (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); declarator = TREE_VALUE (declarator);
decl_attributes (type, attrs, NULL_TREE);
} }
break; break;
...@@ -10087,6 +10106,17 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -10087,6 +10106,17 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
} }
} }
/* 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) if (explicitp == 1)
{ {
error ("only constructors can be declared `explicit'"); error ("only constructors can be declared `explicit'");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment