This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ broken again wrt. GTY desc
- From: Steven Bosscher <stevenb at suse dot de>
- To: nathan at codesourcery dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 19 Jul 2004 19:46:05 +0200
- Subject: Re: C++ broken again wrt. GTY desc
- Organization: SUSE Labs
- References: <200407191936.27695.stevenb@suse.de>
On Monday 19 July 2004 19:36, Steven Bosscher wrote:
> Hello,
>
> Find the bug:
>
> 1.717 (geoffk 04-Jun-02): unsigned u1sel : 1;
> 1.1 (law 11-Aug-97):
> 1.717 (geoffk 04-Jun-02): union lang_decl_u {
> 1.717 (geoffk 04-Jun-02): tree GTY ((tag ("0")))
> template_info; 1.717 (geoffk 04-Jun-02): struct
> cp_binding_level * GTY ((tag ("1"))) level; 1.939 (nathan
> 12-Dec-03): tree GTY ((tag ("2"))) thunk_alias; 1.717 (geoffk
> 04-Jun-02): } GTY ((desc ("%1.u1sel"))) u;
>
> You _can_ _not_ have a switch from GTY desc if the switch has
> three possibilities while the index expression can only be 0
> or 1!
>
> I already fixed one of these not too long ago, now there are
> two new bugs like this: the one showed above, and another one
> immediately below this one. Both are in cp-tree.h.
>
> Nathan, this is your doing. Please fix it, it badly breaks a
> cleanup I have queued for expanding switches.
The obvious patch goes like this:
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.1013
diff -c -3 -p -r1.1013 cp-tree.h
*** cp-tree.h 18 Jul 2004 23:57:30 -0000 1.1013
--- cp-tree.h 19 Jul 2004 17:44:24 -0000
*************** struct lang_decl_flags GTY(())
*** 1544,1572 ****
unsigned this_thunk_p : 1;
union lang_decl_u {
! /* In a FUNCTION_DECL for which DECL_THUNK_P does not hold,
VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this is
DECL_TEMPLATE_INFO. */
tree GTY ((tag ("0"))) template_info;
/* In a NAMESPACE_DECL, this is NAMESPACE_LEVEL. */
struct cp_binding_level * GTY ((tag ("1"))) level;
-
- /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
- THUNK_ALIAS. */
- tree GTY ((tag ("2"))) thunk_alias;
} GTY ((desc ("%1.u1sel"))) u;
union lang_decl_u2 {
! /* This is DECL_ACCESS. */
tree GTY ((tag ("0"))) access;
/* For VAR_DECL in function, this is DECL_DISCRIMINATOR. */
int GTY ((tag ("1"))) discriminator;
-
- /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
- THUNK_VIRTUAL_OFFSET. */
- tree GTY((tag ("2"))) virtual_offset;
} GTY ((desc ("%1.u2sel"))) u2;
};
--- 1544,1568 ----
unsigned this_thunk_p : 1;
union lang_decl_u {
! /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
! THUNK_ALIAS.
! In a FUNCTION_DECL for which DECL_THUNK_P does not hold,
VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this is
DECL_TEMPLATE_INFO. */
tree GTY ((tag ("0"))) template_info;
/* In a NAMESPACE_DECL, this is NAMESPACE_LEVEL. */
struct cp_binding_level * GTY ((tag ("1"))) level;
} GTY ((desc ("%1.u1sel"))) u;
union lang_decl_u2 {
! /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
! THUNK_VIRTUAL_OFFSET.
! Otherwise this is DECL_ACCESS. */
tree GTY ((tag ("0"))) access;
/* For VAR_DECL in function, this is DECL_DISCRIMINATOR. */
int GTY ((tag ("1"))) discriminator;
} GTY ((desc ("%1.u2sel"))) u2;
};
*************** struct lang_decl GTY(())
*** 2827,2837 ****
binfos.) */
#define THUNK_VIRTUAL_OFFSET(DECL) \
! (LANG_DECL_U2_CHECK (FUNCTION_DECL_CHECK (DECL), 0)->virtual_offset)
/* A thunk which is equivalent to another thunk. */
#define THUNK_ALIAS(DECL) \
! (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->decl_flags.u.thunk_alias)
/* For thunk NODE, this is the FUNCTION_DECL thunked to. */
#define THUNK_TARGET(NODE) \
--- 2823,2833 ----
binfos.) */
#define THUNK_VIRTUAL_OFFSET(DECL) \
! (LANG_DECL_U2_CHECK (FUNCTION_DECL_CHECK (DECL), 0)->access)
/* A thunk which is equivalent to another thunk. */
#define THUNK_ALIAS(DECL) \
! (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->decl_flags.u.template_info)
/* For thunk NODE, this is the FUNCTION_DECL thunked to. */
#define THUNK_TARGET(NODE) \