--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-weak "" } */
+/* { dg-require-effective-target tls_emulated } */
+/* { dg-add-options tls } */
+__attribute__((weak))
+__thread int tlsvar = 3;
+/* { dg-final { scan-assembler ".weak_definition ___emutls_t.tlsvar" { target *-*-darwin* } } } */
+/* { dg-final { scan-assembler-not ".private_extern ___emutls_t.tlsvar" { target *-*-darwin* } } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-weak "" } */
+/* { dg-require-visibility "" } */
+/* { dg-require-effective-target tls_emulated } */
+/* { dg-add-options tls } */
+__attribute__((weak))
+__attribute__((visibility ("hidden")))
+__thread int tlsvar = 3;
+/* { dg-final { scan-assembler ".weak_definition ___emutls_t.tlsvar" { target *-*-darwin* } } } */
+/* { dg-final { scan-assembler ".private_extern ___emutls_t.tlsvar" { target *-*-darwin* } } } */
DECL_PRESERVE_P (to) = DECL_PRESERVE_P (decl);
DECL_WEAK (to) = DECL_WEAK (decl);
- if (DECL_ONE_ONLY (decl))
+ if (DECL_ONE_ONLY (decl) || DECL_WEAK (decl))
{
TREE_STATIC (to) = TREE_STATIC (decl);
TREE_PUBLIC (to) = TREE_PUBLIC (decl);
DECL_VISIBILITY (to) = DECL_VISIBILITY (decl);
- make_decl_one_only (to, DECL_ASSEMBLER_NAME (to));
}
else
TREE_STATIC (to) = 1;
+ if (DECL_ONE_ONLY (decl))
+ make_decl_one_only (to, DECL_ASSEMBLER_NAME (to));
+
DECL_VISIBILITY_SPECIFIED (to) = DECL_VISIBILITY_SPECIFIED (decl);
DECL_INITIAL (to) = DECL_INITIAL (decl);
DECL_INITIAL (decl) = NULL;