From 38f01e5a57f979f7427e99be377b4717a330cf7a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 1 Oct 1998 12:31:22 +0000 Subject: [PATCH] cp-tree.h (FORMAT_VBASE_NAME): New macro. * cp-tree.h (FORMAT_VBASE_NAME): New macro. * class.c (build_vbase_pointer): Use it. * rtti.c (expand_class_desc): Likewise. * tree.c (build_vbase_pointer_fields): Likewise. From-SVN: r22713 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/class.c | 3 +-- gcc/cp/cp-tree.h | 7 +++++++ gcc/cp/rtti.c | 3 +-- gcc/cp/tree.c | 5 ++--- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8f358d87e81..bb2a13bcc64 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +1998-10-01 Jason Merrill + + * cp-tree.h (FORMAT_VBASE_NAME): New macro. + * class.c (build_vbase_pointer): Use it. + * rtti.c (expand_class_desc): Likewise. + * tree.c (build_vbase_pointer_fields): Likewise. + Thu Oct 1 10:43:45 1998 Nick Clifton * decl.c (start_decl): Add invocation of diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 624c05898db..8e7d715eb89 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -146,9 +146,8 @@ build_vbase_pointer (exp, type) tree exp, type; { char *name; + FORMAT_VBASE_NAME (name, type); - name = (char *) alloca (TYPE_NAME_LENGTH (type) + sizeof (VBASE_NAME) + 1); - sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (type)); return build_component_ref (exp, get_identifier (name), NULL_TREE, 0); } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8d1247e7192..8fe0bd45b1f 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2140,6 +2140,13 @@ extern int current_function_parms_stored; && IDENTIFIER_POINTER (ID_NODE)[2] == 'b' \ && IDENTIFIER_POINTER (ID_NODE)[3] == JOINER) +/* Store the vbase pointer field name for type TYPE into pointer BUF. */ +#define FORMAT_VBASE_NAME(BUF,TYPE) do { \ + BUF = (char *) alloca (TYPE_ASSEMBLER_NAME_LENGTH (TYPE) \ + + sizeof (VBASE_NAME) + 1); \ + sprintf (BUF, VBASE_NAME_FORMAT, TYPE_ASSEMBLER_NAME_STRING (TYPE)); \ +} while (0) + #define TEMP_NAME_P(ID_NODE) (!strncmp (IDENTIFIER_POINTER (ID_NODE), AUTO_TEMP_NAME, sizeof (AUTO_TEMP_NAME)-1)) #define VFIELD_NAME_P(ID_NODE) (!strncmp (IDENTIFIER_POINTER (ID_NODE), VFIELD_NAME, sizeof(VFIELD_NAME)-1)) diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 01c4a861ec2..63a734db399 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -801,8 +801,7 @@ expand_class_desc (tdecl, type) char *name; tree field; - name = (char *) alloca (TYPE_NAME_LENGTH (t)+sizeof (VBASE_NAME)+1); - sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (t)); + FORMAT_VBASE_NAME (name, t); field = lookup_field (type, get_identifier (name), 0, 0); offset = size_binop (FLOOR_DIV_EXPR, DECL_FIELD_BITPOS (field), size_int (BITS_PER_UNIT)); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 1a87a5128e1..e66cbff5b60 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -882,8 +882,7 @@ build_vbase_pointer_fields (rec) if (TREE_VIA_VIRTUAL (base_binfo)) { int j; - char *name = (char *)alloca (TYPE_NAME_LENGTH (basetype) - + sizeof (VBASE_NAME) + 1); + char *name; /* The offset for a virtual base class is only used in computing virtual function tables and for initializing virtual base @@ -903,7 +902,7 @@ build_vbase_pointer_fields (rec) )) goto got_it; } - sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (basetype)); + FORMAT_VBASE_NAME (name, basetype); decl = build_lang_field_decl (FIELD_DECL, get_identifier (name), build_pointer_type (basetype)); /* If you change any of the below, take a look at all the -- 2.30.2