ir_entity *irentity = entity->variable.v.entity;
- if (tq & TYPE_QUALIFIER_CONST) {
+ if (tq & TYPE_QUALIFIER_CONST
+ && get_entity_owner(irentity) != get_tls_type()) {
add_entity_linkage(irentity, IR_LINKAGE_CONSTANT);
}
set_atomic_ent_value(irentity, value);
size_t l = strlen(entity->base.symbol->string);
char buf[l + sizeof(".%u")];
snprintf(buf, sizeof(buf), "%s.%%u", entity->base.symbol->string);
- ident *const id = id_unique(buf);
-
+ ident *const id = id_unique(buf);
ir_entity *const irentity = new_d_entity(var_type, id, irtype, dbgi);
if (type->base.qualifiers & TYPE_QUALIFIER_VOLATILE) {