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


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 );

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.

--Phil


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