aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2024-04-20 01:40:00 -0700
committerMichael Forney <mforney@mforney.org>2024-04-20 01:53:14 -0700
commit92e397469d49e5d6dd053b061ec2a138a3dd1ef0 (patch)
tree52b0f0a820268dd1ee459a00a40d20479731ca0f
parent7837920950b4afc06cff96d04f27149866251378 (diff)
qbe: Disallow address of TLS variables in static initializers
The address of an object with thread storage duration is not an address constant.
-rw-r--r--qbe.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/qbe.c b/qbe.c
index 571cfaf..a360d03 100644
--- a/qbe.c
+++ b/qbe.c
@@ -1277,8 +1277,8 @@ dataitem(struct expr *expr, unsigned long long size)
if (expr->kind != EXPRIDENT)
error(&tok.loc, "initializer is not a constant expression");
decl = expr->u.ident.decl;
- if (decl->value->kind != VALUE_GLOBAL)
- fatal("not a global");
+ if (decl->kind == DECLOBJECT && decl->u.obj.storage != SDSTATIC)
+ error(&tok.loc, "initializer is not a constant expression");
emitvalue(decl->value);
break;
case EXPRBINARY: