Re: Creating a variable declaration of custom type.

2007-01-17 Thread Revital1 Eres
[EMAIL PROTECTED] wrote on 16/01/2007 17:45:59: > I succeeded to do it as follows: > > tree type_decl = lookup_name(get_identifier("MyType")); > tree type_ptr = build_pointer_type(TREE_TYPE(type_decl)); > tree var_decl = build(VAR_DECL, get_identifier("t"), type_ptr); > pushdecl(var_decl); > > I

Re: Creating a variable declaration of custom type.

2007-01-16 Thread Ferad Zyulkyarov
I succeeded to do it as follows: tree type_decl = lookup_name(get_identifier("MyType")); tree type_ptr = build_pointer_type(TREE_TYPE(type_decl)); tree var_decl = build(VAR_DECL, get_identifier("t"), type_ptr); pushdecl(var_decl); It may not be a perfect solution but for now it works. On 1/16/0

Re: Creating a variable declaration of custom type.

2007-01-16 Thread Ferad Zyulkyarov
Hi, Best way to figure this out is to write a simple 5 line testcase that defines a structure type and also defines a pointer to that type, and then step through gcc to see what it does. Try putting breakpoints in finish_struct and build_pointer_type. I tried with the advised test case but ag

Re: Creating a variable declaration of custom type.

2007-01-15 Thread Jim Wilson
Ferad Zyulkyarov wrote: type_id = get_identifier("MyType"); type_node = make_node(POINTER_TYPE); TYPE_NAME(type_node) = type_id; var_decl = build(VAR_DECL, get_identifier("t"), type_node); Best way to figure this out is to write a simple 5 line testcase that defines a structure type and also d

Re: Creating a variable declaration of custom type.

2007-01-15 Thread Ferad Zyulkyarov
Hi again, I think that the type of type_node is missing. Try to add TREE_TYPE (type_node); For example TREE_TYPE (type_node) = integer_type_node. (if MyType is int). "MyType" is a struct (of other again coumpound types) and will not work with already existing type nodes like integer_type_node

Re: Creating a variable declaration of custom type.

2007-01-15 Thread Revital1 Eres
> tree type_id, type_node, var_decl; > > type_id = get_identifier("MyType"); > type_node = make_node(POINTER_TYPE); > TYPE_NAME(type_node) = type_id; > var_decl = build(VAR_DECL, get_identifier("t"), type_node); > > But, when I compile my source with the modified GCC (as above) I get > an error:

Creating a variable declaration of custom type.

2007-01-15 Thread Ferad Zyulkyarov
Hi, When the code is being parsed in c-parser.c I try to transparently create a variable declaration of custom type within the code being compiled. The name of the custom type is "MyType" (defined in some header file by typedef). In my source file I have a function: void foo() { ...; } At the