- To: zahed khurasani <sdzahed@xxxxxxxxx>
- Subject: Re: Global Definition Vs Global Declaration
- From: Ian Lance Taylor <iant@xxxxxxxxxx>
- Date: Thu, 05 Apr 2012 21:23:26 -0700
- Cc: Alexander Monakov <amonakov@xxxxxxxxx>, gcc-help <gcc-help@xxxxxxxxxxx>
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- In-reply-to: <CAAb5P2uF=aJ-y9O0BZq3+Qv4smJRmQ7161yg6PTwepo3NNQ5ew@mail.gmail.com> (zahed khurasani's message of "Thu, 5 Apr 2012 21:16:55 -0400")
- User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
zahed khurasani <sdzahed@xxxxxxxxx> writes:
>> OK, I actually tried it. When I try this with current mainline, I see
>> that DECL_EXTERNAL is set for "extern int j;" and is not set for "int
>> i;". Also TREE_STATIC is set for "int i;" but not for "extern int j;".
>
> Hmm strange. I am not sure if I am doing this wrong. Here's the sample
> code that I am running this on:
>
> // Global decls
> static int staticint;
> extern int extint;
> int globalint;
>
> int main(void)
> {
> int a[10],i, *p;
> globalint=0;
> return 1;
> }
>
> And here is the output from the plugin code:
>
> Glob var: staticint decl_external:0 tree_static:1 complete:1 common: 0
> Glob var: extint decl_external:1 tree_static:0 complete:1 common: 1
> Glob var: globalint decl_external:1 tree_static:0 complete:1 common: 1
>
> decl_external is set for both globalint and extint. I am trying this
> with 4.6.2 source.
I was checking the fields by running cc1 in the debugger. I was looking
at the point where decls are passed to wrapup_global_declaration_2.
I tried 4.6, and the situation there seems more complicated for some
reason. Both "extern int j;" and "int i;" have two decls. Both decls
for j, and one of the ones for i, are DECL_EXTERN and DECL_COMMON. The
other decl for i is TREE_STATIC and DECL_COMMON but not DECL_EXTERN.
I'm not sure why this is.
Ian
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]