This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: declare global in gimple
- From: Mikhail Maltsev <maltsevm at gmail dot com>
- To: k9119911 <xxx-protoss at yahoo dot com dot tw>, gcc-help at gcc dot gnu dot org
- Date: Sat, 22 Aug 2015 05:21:31 +0300
- Subject: Re: declare global in gimple
- Authentication-results: sourceware.org; auth=none
- References: <1440125475388-1178703 dot post at n5 dot nabble dot com> <55D6A521 dot 8000202 at gmail dot com> <1440159909077-1178812 dot post at n5 dot nabble dot com>
On 08/21/2015 03:25 PM, k9119911 wrote:
> Hi Mikhail
>
> Thank you so much.
>
> It works now and declared in .bss section.
>
> However, I just wonder why it works.
>
> Because we need to specify in frontend:
>
> TREE_PUBLIC(decl) = 1
>
> but we do the opposite in middle-end:
>
> TREE_PUBLIC(decl) = 0
>
> Why they are different? It is confusing.
That is strange. The comment in tree.h says:
/* In a VAR_DECL, FUNCTION_DECL, NAMESPACE_DECL or TYPE_DECL,
nonzero means name is to be accessible from outside this translation unit.
In an IDENTIFIER_NODE, nonzero means an external declaration
accessible from outside this translation unit was previously seen
for this name in an inner scope. */
#define TREE_PUBLIC(NODE) ((NODE)->base.public_flag)
So, it should not be different. It's enough to set TREE_STATIC(decl) = 1, then
you don't necessarily need to set TREE_PUBLIC to make the variable global.
>
> Thanks
>
>
>
> --
> View this message in context: http://gcc.1065356.n5.nabble.com/declare-global-in-gimple-tp1178703p1178812.html
> Sent from the gcc - Help mailing list archive at Nabble.com.
>
--
Regards,
Mikhail Maltsev