This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR C++/9021 and 11005 -TAKE 2
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>, Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 18 Dec 2003 20:07:55 +1100 (EST)
- Subject: Re: [PATCH] Fix PR C++/9021 and 11005 -TAKE 2
--- Gabriel Dos Reis wrote:
> More stringent:
>
> (1) allow attributes only when defining the class;
Hi,
Documentation (extend.texi) states that type attributes are to be specified on
"@emph{definition}". This patch prevents the type attributes that were
specified on definition from being overwitten in C++.
Bootstrapped, regtested on i686-pc-mingw32.
cp/ChangeLog
2003-12-18 Danny Smith <dannysmith@users,sourceforge.net>
PR c++/9021
PR c++/11005
* parser.c (cp_parser_elaborated_type_specifier): Warn about
attributes and discard.
* decl.c (xref_tag): Don't overwrite existing attributes with
NULL_TREE.
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1163
diff -c -3 -p -r1.1163 decl.c
*** decl.c 17 Dec 2003 04:45:51 -0000 1.1163
--- decl.c 18 Dec 2003 08:10:20 -0000
*************** xref_tag (enum tag_types tag_code, tree
*** 9437,9443 ****
redeclare_class_template (t, current_template_parms);
}
! TYPE_ATTRIBUTES (t) = attributes;
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
--- 9437,9451 ----
redeclare_class_template (t, current_template_parms);
}
! /* Add attributes only when defining a type. */
! if (attributes)
! {
! /* The only place that xref_tag is called with non-null
! attributes is in cp_parser_class_head(), when defining a
! class. */
! my_friendly_assert (TYPE_ATTRIBUTES (t) == NULL_TREE, 20031218);
! TYPE_ATTRIBUTES (t) = attributes;
! }
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
Index: parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.135
diff -c -3 -p -r1.135 parser.c
*** parser.c 16 Dec 2003 16:09:13 -0000 1.135
--- parser.c 18 Dec 2003 08:10:47 -0000
*************** cp_parser_elaborated_type_specifier (cp_
*** 8978,8985 ****
definition of a new type; a new type can only be declared in a
declaration context. */
type = xref_tag (tag_type, identifier,
! attributes,
(is_friend
|| !is_declaration
|| cp_lexer_next_token_is_not (parser->lexer,
--- 8978,8989 ----
definition of a new type; a new type can only be declared in a
declaration context. */
+ /* Warn about attributes. They are ignored. */
+ if (attributes)
+ warning ("type attributes are honored only at type definition");
+
type = xref_tag (tag_type, identifier,
! /* attributes = */ NULL_TREE,
(is_friend
|| !is_declaration
|| cp_lexer_next_token_is_not (parser->lexer,
http://personals.yahoo.com.au - Yahoo! Personals
New people, new possibilities. FREE for a limited time.