[hackers] [scc] Mark as constant nodes address of static variables || Roberto E. Vargas Caballero
commit b163099eeca09217177482d7502bf8d6703dad76
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Jan 18 17:39:03 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Jan 18 17:39:03 2016 +0100
Mark as constant nodes address of static variables
This operation generates a constant node which can be used
in initializers.
diff --git a/cc1/expr.c b/cc1/expr.c
index 5494505..ff3528e 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -544,6 +544,8 @@ incdec(Node *np, char op)
static Node *
address(char op, Node *np)
{
+ Node *new;
+
if (BTYPE(np) != FTN) {
chklvalue(np);
if (np->symbol && (np->sym->flags & ISREGISTER))
_AT_@ -554,7 +556,11 @@ address(char op, Node *np)
return new;
}
}
- return node(op, mktype(np->type, PTR, 0, NULL), np, NULL);
+ new = node(op, mktype(np->type, PTR, 0, NULL), np, NULL);
+
+ if (np->symbol && np->sym->flags & (ISGLOBAL|ISLOCAL|ISPRIVATE))
+ new->constant = 1;
+ return new;
}
static Node *
Received on Mon Jan 18 2016 - 17:51:56 CET
This archive was generated by hypermail 2.3.0
: Mon Jan 18 2016 - 18:00:54 CET