ref: 97c2741373af5f85c0538a671c51d22bb3ef1d97
parent: 2d9f4dcdec7a6a85817ec1a58b7f106aa9f43b0d
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Aug 8 12:08:57 EDT 2014
Fix parsing of 'T' elements 'T' is used for static variables that are not global, and they can appear in outer contex or in the context of a function. If they appear in the context of function they have to be stored in the local pool, and if they appear in the outer then they must be stored in the global spool.
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -1,5 +1,6 @@
typedef struct {
+ char public;
union {
struct {
char type;
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -89,7 +89,7 @@
variable(char *token)
{
Symbol *sym;
- char op;
+ char op, public = 0;
Node *np = newnode();
switch (token[0]) {
@@ -102,15 +102,17 @@
op = REGISTER;
break;
case 'T':
- sym = local(token);
+ sym = (funbody) ? local(token) : global(token);
op = STATIC;
break;
case 'G':
sym = global(token);
op = STATIC;
+ public = 1;
break;
}
+ sym->public = public;
np->u.sym = sym;
np->op = op;
np->type = sym->u.v.type;