On 17 September 2010 02:05, Philip Herron <redbrain@xxxxxxxxxxx> wrote: > Hey all > > Been asking on irc tonight but i think many might be sensible and > sleeping. Anyway's this has been bugging me for some time, if i create > a VAR_DECL such as: > > tree test = build_decl( UNKNOWN_LOCATION, VAR_DECL, > get_identifier("test"), > integer_type_node); > > TREE_CONSTANT (test) = 1; > DECL_ARTIFICIAL (test) = 1; > TREE_STATIC (test) = 1; > TREE_READONLY (test) = 1; > TREE_USED (test) = 1; > DECL_INITIAL (test) = build_int_cst(integer_type_node, 1234 ); > > And i add it to the vector for: > > wrapup_global_declarations( global_vec, global_vec_len ); > > check_global_declarations( global_vec, global_vec_len ); > emit_debug_global_declarations( global_vec, global_vec_len ); > > cgraph_finalize_compilation_unit( ); > > This declaration is not compiled, though my FUNCTION_DCEL 's are > compiled fine though with functions i call: > > gimplify_function_tree( retval ); > > cgraph_add_new_function(retval, false); > cgraph_finalize_function(retval, true); > > So they are gimplified though not sure what i should be calling on > these VAR_DECL's, i just tried: > > set_user_assembler_name (test, "test"); > layout_decl (test, 0); > rest_of_decl_compilation (test, 1, 0); > > gimple_seq seq_p = NULL; > bool x = gimplify_stmt( &test, &seq_p ); > debug("x=<%i>!\n", (int)x ); > > But no luck it does gimplify but it seems to not know where to put the > stmt and then the tree goes null and i get a sigsegv later on. Not > quite sure how to get this working. > > --Phil > Forgot to mention i think it could be a problem since the VAR_DECL has no DECL_CONTEXT, i think i seen some gdb trace on a segfault and it was due to no context. Maybe i am missing something super small :) --Phil