Re : Re : [GENERIC] problem when adding 2 VAR_DEC in the main function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






----- Message d'origine ----
De : charfi asma <charfiasma@xxxxxxxx>
À : Philip Herron <redbrain@xxxxxxxxxxx>
Cc : gcc-help@xxxxxxxxxxx
Envoyé le : Jeu 21 octobre 2010, 12h 18min 49s
Objet : Re : [GENERIC] problem when adding 2 VAR_DEC in the main function





----- Message d'origine ----
De : Philip Herron <redbrain@xxxxxxxxxxx>
À : Ian Lance Taylor <iant@xxxxxxxxxx>
Cc : charfi asma <charfiasma@xxxxxxxx>; gcc-help@xxxxxxxxxxx
Envoyé le : Mer 20 octobre 2010, 19h 52min 27s
Objet : Re: [GENERIC] problem when adding 2 VAR_DEC in the main function

On 20 October 2010 15:12, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
> On Wed, Oct 20, 2010 at 3:30 AM, charfi asma <charfiasma@xxxxxxxx> wrote:
>
>> it seems that  the function gimplify_var_or_parm_decl consider that I have a
>> duplicate declaration.
>
> The error means specifically that the variable was not seen in a
> BIND_EXPR.  Did you add the second variable to the BIND_EXPR like the
> first?  Was the BIND_EXPR passed to the gimplifier?
>
> Put a breakpoint on gimplify_bind_expr and make sure that the variable
> is seen there.
>
> Ian
>

one thing i found very useful in learning to code gcc front-ends is
added debug_tree (tree) in your gimplify expression lang_hook this
will print debug info about the tree's which get gimplified.

--Phil


Hello,

thank you very much Ian and Phill, Now it works (I used the debug_tree that I 
find also very helpfull especially for the newbies in coding gcc fe ;)
the error comes (as Ian said from the BIND_EXP) I added my 2 var decl to the 
same tree (declare_vars) and I used TREE_CHAIN to obtain one tree (just like the 

gcalc fe):
tree bind = NULL_TREE;
tree bl = build_block(declare_vars, NULL_TREE, main_fn_decl, NULL_TREE);
DECL_INITIAL(main_fn_decl) = bl;
bind = build3( BIND_EXPR, void_type_node, BLOCK_VARS(bl), NULL_TREE, bl );

now I want to add a class (a record type) with attributes and methods and after 
in the main I will add an object of type myclass and call one of the methods.
shoud I add another bind ?
is there a documentation on how to write this using generic other than the 
tree.def ?
I will try to do it and if I get erros (hope not) I will certainly ask in the 
gcc-help mailing list ;)

Asma


Hello, 

here I am ;)
I tried to add a class with attribute and method
my problem is that the method is never added to the TYPE_METHOD list of the 
RECROD_TYPE:

     tree class_type = make_node(RECORD_TYPE);
    TYPE_PACKED(class_type) = false;
    TYPE_NAME(class_type) = get_identifier("MyClass");

    tree __field1 = build_decl(BUILTINS_LOCATION, FIELD_DECL, 
get_identifier("MyAttribute"), integer_type_node);
    DECL_CONTEXT(__field1) = class_type;
    DECL_PACKED(__field1) = false;
    TYPE_FIELDS(class_type) = __field1;

  
    tree __field2 = build_decl(BUILTINS_LOCATION, FUNCTION_DECL, 
get_identifier("MyOperation"), void_type_node);
    DECL_CONTEXT(__field2) = class_type; 
    TREE_PUBLIC(__field2) = true;
    DECL_ARGUMENTS(__field2) = NULL_TREE;
    DECL_PACKED(__field2) = false;
    TYPE_METHODS(class_type) = __field2;
    layout_type(class_type);
    rest_of_type_compilation(class_type, 1);

debug_tree(class_type);

the result of the debug class_type is : (with no ref to MyOperation )

<record_type 0xb760d3c0 MyClass SI
            size <integer_cst 0xb75f1240 type <integer_type 0xb7602060> constant 
32>
            unit size <integer_cst 0xb75f1078 type <integer_type 0xb7602000> 
constant 4>
            align 32 symtab 0 alias set -1 canonical type 0xb760d3c0
            fields <field_decl 0xb75fa2e0 MyAttribute
            type <integer_type 0xb76022a0 public SI 
            size <integer_cst 0xb75f1240 32> 
            unit size <integer_cst 0xb75f1078 4>
            align 32 symtab 0 alias set -1 canonical type 0xb76022a0 precision 
32 

            min <integer_cst 0xb75f11f8 -2147483648> max <integer_cst 0xb75f1210 
2147483647>
            pointer_to_this <pointer_type 0xb76029c0>
            >
            SI file <built-in> line 0 col 0 
            size <integer_cst 0xb75f1240 32> 
            unit size <integer_cst 0xb75f1078 4>
            align 32 offset_align 128
            offset <integer_cst 0xb75f1090 constant 0>
            bit offset <integer_cst 0xb75f14b0 constant 0> context <record_type 
0xb760d3c0 MyClass>
            >
>

did I miss sth to add the method in the record type ?

thanks

Asma






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux