re PR debug/66653 (ice in gen_type_die_with_usage, at dwarf2out.c:20876)
[gcc.git] / gcc / cp / pt.c
index 874f29f02c66fa721b543159c6dc8df3090ca1a9..6b73d49ce29c3d69db6485a6c6064ca9e6a1c9c5 100644 (file)
@@ -11467,8 +11467,9 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
                  }
                SET_DECL_VALUE_EXPR (r, ve);
              }
-           if (TREE_STATIC (r) || DECL_EXTERNAL (r))
-             set_decl_tls_model (r, decl_tls_model (t));
+           if (CP_DECL_THREAD_LOCAL_P (r)
+               && !processing_template_decl)
+             set_decl_tls_model (r, decl_default_tls_model (r));
          }
        else if (DECL_SELF_REFERENCE_P (t))
          SET_DECL_SELF_REFERENCE_P (r);
@@ -15696,7 +15697,7 @@ tsubst_copy_and_build (tree t,
            && !processing_template_decl
            && !cp_unevaluated_operand
            && (TREE_STATIC (r) || DECL_EXTERNAL (r))
-           && DECL_THREAD_LOCAL_P (r))
+           && CP_DECL_THREAD_LOCAL_P (r))
          {
            if (tree wrap = get_tls_wrapper_fn (r))
              /* Replace an evaluated use of the thread_local variable with