objc.dg/const-str-1.m regression
Richard Henderson
rth@redhat.com
Tue Dec 11 17:16:00 GMT 2001
On Tue, Dec 11, 2001 at 03:38:10PM -0800, Stan Shebs wrote:
> Richard Henderson wrote:
> > On Tue, Dec 11, 2001 at 10:35:56PM +0000, GCC regression checker wrote:
> > > powerpc-eabisim objc.sum objc.dg/const-str-1.m
> > > native objc.sum objc.dg/const-str-1.m
> >
> > This may be mine...
> >
> > > + * objc/objc-act.c (build_constructor): Cast initializer values
> > > + to the proper field types.
>
> That's what it's looking like. You shoulda waited for the ObjC
> maintainer to review your change... :-)
;-)
> I'd guess that the correct fix is in synth_module_prologue,
> do a better job of filling in constant_string_type.
Another possible solution is to skip the casting step in
build_constructor if there are no fields, since this can
only happen under error conditions.
However, this appears to work. Note the comment wrt
synth_module_prologue vs debugging. Which do you prefer?
r~
* objc/objc-act.c (build_string_class_template): New.
(build_objc_string_object): Call it.
Index: objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.114
diff -u -p -r1.114 objc-act.c
--- objc-act.c 2001/12/11 18:24:15 1.114
+++ objc-act.c 2001/12/12 01:02:24
@@ -278,6 +278,7 @@ static tree lookup_protocol_in_reflist
static tree create_builtin_decl PARAMS ((enum tree_code,
tree, const char *));
static void setup_string_decl PARAMS ((void));
+static void build_string_class_template PARAMS ((void));
static tree my_build_string PARAMS ((int, const char *));
static void build_objc_symtab_template PARAMS ((void));
static tree init_def_list PARAMS ((tree));
@@ -1231,11 +1232,39 @@ synth_module_prologue ()
/* Forward declare constant_string_id and constant_string_type. */
if (!constant_string_class_name)
constant_string_class_name = STRING_OBJECT_CLASS_NAME;
-
+
constant_string_id = get_identifier (constant_string_class_name);
constant_string_type = xref_tag (RECORD_TYPE, constant_string_id);
}
+/* Predefine the following data type:
+
+ struct STRING_OBJECT_CLASS_NAME
+ {
+ Object isa;
+ char *cString;
+ unsigned int length;
+ }; */
+
+static void
+build_string_class_template ()
+{
+ tree field_decl, field_decl_chain;
+
+ field_decl = create_builtin_decl (FIELD_DECL, id_type, "isa");
+ field_decl_chain = field_decl;
+
+ field_decl = create_builtin_decl (FIELD_DECL,
+ build_pointer_type (char_type_node),
+ "cString");
+ chainon (field_decl_chain, field_decl);
+
+ field_decl = create_builtin_decl (FIELD_DECL, unsigned_type_node, "length");
+ chainon (field_decl_chain, field_decl);
+
+ finish_struct (constant_string_type, field_decl_chain, NULL_TREE);
+}
+
/* Custom build_string which sets TREE_TYPE! */
static tree
@@ -1286,8 +1315,13 @@ build_objc_string_object (strings)
string = combine_strings (strings);
TREE_SET_CODE (string, STRING_CST);
length = TREE_STRING_LENGTH (string) - 1;
+
+ /* We could not properly create NXConstantString in synth_module_prologue,
+ because that's called before debugging is initialized. Do it now. */
+ if (TYPE_FIELDS (constant_string_type) == NULL_TREE)
+ build_string_class_template ();
- /* & ((NXConstantString) {0, string, length}) */
+ /* & ((NXConstantString) { NULL, string, length }) */
if (flag_next_runtime)
{
More information about the Gcc-patches
mailing list