diff options
author | Michael Forney <mforney@mforney.org> | 2024-04-20 01:40:00 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2024-04-20 01:53:14 -0700 |
commit | 92e397469d49e5d6dd053b061ec2a138a3dd1ef0 (patch) | |
tree | 52b0f0a820268dd1ee459a00a40d20479731ca0f | |
parent | 7837920950b4afc06cff96d04f27149866251378 (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.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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: |