tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] How to tell if variable is global?


From: Joshua Phillips
Subject: [Tinycc-devel] How to tell if variable is global?
Date: Thu, 1 Nov 2007 14:40:09 +0000
User-agent: KMail/1.9.7

How can I tell if a variable has global scope?
possible methods I have considered:
  -  iterating through global_stack or local_stack (yuk)
  -  if ((sym->r & (VT_VALMASK | VT_LVAL)) == (VT_CONST | VT_LVAL))  - is this 
reliable?
  -  encoding a flag in the symbol structure to mark it as global

what do you think?

I need this because I'm half way through fixing the following:
> int a, a;
should compile if it is global, but not if it is local. tcc ignores.
> int a,
> short a;
should never compile. tcc ignores.
> int a;
> {
>     int a;
> }
inside a function should compile though.
> void foo(int a, int a)
should raise an error, tcc ignores.
Problems also exist for struct/union/enum




reply via email to

[Prev in Thread] Current Thread [Next in Thread]