This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: global declarations


Philip Herron <redbrain@gcc.gnu.org> writes:

> On 17 September 2010 06:38, Ian Lance Taylor <iant@google.com> wrote:
>> Philip Herron <redbrain@gcc.gnu.org> writes:
>>
>>> 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 );
>>
>> By setting TREE_CONSTANT and TREE_STATIC, you are marking this decl as a
>> static const, more or less like a C++ const. ÂIt will only be written
>> out if something else refers to it. ÂYou probably don't want to set
>> TREE_CONSTANT.
>>
>
> I just tried that and played with and added in extras to see if they
> help and it still didn't output any code.
>
>    tree test = build_decl( UNKNOWN_LOCATION, VAR_DECL,
> 			  get_identifier("test"),
> 			  integer_type_node);
>
>   DECL_ARTIFICIAL (test) = 1;
>   TREE_PUBLIC(test) = 1;
>   TREE_USED (test) = 1;
>   DECL_INITIAL (test) = build_int_cst(integer_type_node, 12345 );

But now you don't have TREE_STATIC.

> I am trying to follow what the c front-end is doing but
> gimplify_expression isn't called on a toplevel global VAR_DECL, since
> i wanted to see the debug_tree of the decl, though code is still
> output for it. I might be able to run though its write-globals
> function and call debug_tree there to see the difference.

Certainly you can always call rest_of_decl_compilation, but the question
is why that isn't happening for your case when you call
wrapup_global_declarations.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]