re PR c++/79288 (TLS model wrong for static data members since r241137)

PR c++/79288
	* decl.c (grokdeclarator): For static data members, handle thread_p
	only after handling inline.

	* g++.dg/tls/pr79288.C: New test.

From-SVN: r245488
This commit is contained in:
Jakub Jelinek 2017-02-15 18:09:18 +01:00 committed by Jakub Jelinek
parent 1eb08f5270
commit 4f5e5fcba8
4 changed files with 48 additions and 8 deletions

View File

@ -1,3 +1,9 @@
2017-02-15 Jakub Jelinek <jakub@redhat.com>
PR c++/79288
* decl.c (grokdeclarator): For static data members, handle thread_p
only after handling inline.
2017-02-14 Marek Polacek <polacek@redhat.com>
PR c++/79420

View File

@ -12063,14 +12063,6 @@ grokdeclarator (const cp_declarator *declarator,
: input_location,
VAR_DECL, unqualified_id, type);
set_linkage_for_static_data_member (decl);
if (thread_p)
{
CP_DECL_THREAD_LOCAL_P (decl) = true;
if (!processing_template_decl)
set_decl_tls_model (decl, decl_default_tls_model (decl));
if (declspecs->gnu_thread_keyword_p)
SET_DECL_GNU_TLS_P (decl);
}
if (concept_p)
error ("static data member %qE declared %<concept%>",
unqualified_id);
@ -12091,6 +12083,15 @@ grokdeclarator (const cp_declarator *declarator,
definition is provided, unless this is an inline
variable. */
DECL_EXTERNAL (decl) = 1;
if (thread_p)
{
CP_DECL_THREAD_LOCAL_P (decl) = true;
if (!processing_template_decl)
set_decl_tls_model (decl, decl_default_tls_model (decl));
if (declspecs->gnu_thread_keyword_p)
SET_DECL_GNU_TLS_P (decl);
}
}
else
{

View File

@ -1,3 +1,8 @@
2017-02-15 Jakub Jelinek <jakub@redhat.com>
PR c++/79288
* g++.dg/tls/pr79288.C: New test.
2017-02-15 Marek Polacek <polacek@redhat.com>
PR c/79515

View File

@ -0,0 +1,28 @@
// PR c++/79288
// { dg-do compile { target nonpic } }
// { dg-require-effective-target tls }
// { dg-options "-O2" }
// { dg-final { scan-assembler-not "@tpoff" { target i?86-*-* x86_64-*-* } } }
struct S
{
static __thread int *p;
};
template <int N>
struct T
{
static __thread int *p;
};
int *
foo ()
{
return S::p;
}
int *
bar ()
{
return T<0>::p;
}