mirror of git://gcc.gnu.org/git/gcc.git
decl.c (start_decl): Improve two error_at locations.
/cp 2019-01-07 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (start_decl): Improve two error_at locations. (expand_static_init): Likewise. /testsuite 2019-01-07 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/diagnostic/constexpr1.C: New. * g++.dg/diagnostic/thread1.C: Likewise. From-SVN: r267662
This commit is contained in:
parent
33a5d8ccb5
commit
2c86a5741f
|
|
@ -1,3 +1,8 @@
|
||||||
|
2019-01-07 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
* decl.c (start_decl): Improve two error_at locations.
|
||||||
|
(expand_static_init): Likewise.
|
||||||
|
|
||||||
2019-01-07 Marek Polacek <polacek@redhat.com>
|
2019-01-07 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
PR c++/88741 - wrong error with initializer-string.
|
PR c++/88741 - wrong error with initializer-string.
|
||||||
|
|
|
||||||
|
|
@ -5235,10 +5235,12 @@ start_decl (const cp_declarator *declarator,
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
if (CP_DECL_THREAD_LOCAL_P (decl))
|
if (CP_DECL_THREAD_LOCAL_P (decl))
|
||||||
error ("%qD declared %<thread_local%> in %<constexpr%> function",
|
error_at (DECL_SOURCE_LOCATION (decl),
|
||||||
decl);
|
"%qD declared %<thread_local%> in %<constexpr%> function",
|
||||||
|
decl);
|
||||||
else if (TREE_STATIC (decl))
|
else if (TREE_STATIC (decl))
|
||||||
error ("%qD declared %<static%> in %<constexpr%> function", decl);
|
error_at (DECL_SOURCE_LOCATION (decl),
|
||||||
|
"%qD declared %<static%> in %<constexpr%> function", decl);
|
||||||
else
|
else
|
||||||
ok = true;
|
ok = true;
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
|
@ -8253,18 +8255,18 @@ expand_static_init (tree decl, tree init)
|
||||||
if (CP_DECL_THREAD_LOCAL_P (decl) && DECL_GNU_TLS_P (decl)
|
if (CP_DECL_THREAD_LOCAL_P (decl) && DECL_GNU_TLS_P (decl)
|
||||||
&& !DECL_FUNCTION_SCOPE_P (decl))
|
&& !DECL_FUNCTION_SCOPE_P (decl))
|
||||||
{
|
{
|
||||||
|
location_t dloc = DECL_SOURCE_LOCATION (decl);
|
||||||
if (init)
|
if (init)
|
||||||
error ("non-local variable %qD declared %<__thread%> "
|
error_at (dloc, "non-local variable %qD declared %<__thread%> "
|
||||||
"needs dynamic initialization", decl);
|
"needs dynamic initialization", decl);
|
||||||
else
|
else
|
||||||
error ("non-local variable %qD declared %<__thread%> "
|
error_at (dloc, "non-local variable %qD declared %<__thread%> "
|
||||||
"has a non-trivial destructor", decl);
|
"has a non-trivial destructor", decl);
|
||||||
static bool informed;
|
static bool informed;
|
||||||
if (!informed)
|
if (!informed)
|
||||||
{
|
{
|
||||||
inform (DECL_SOURCE_LOCATION (decl),
|
inform (dloc, "C++11 %<thread_local%> allows dynamic "
|
||||||
"C++11 %<thread_local%> allows dynamic initialization "
|
"initialization and destruction");
|
||||||
"and destruction");
|
|
||||||
informed = true;
|
informed = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
2019-01-07 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
* g++.dg/diagnostic/constexpr1.C: New.
|
||||||
|
* g++.dg/diagnostic/thread1.C: Likewise.
|
||||||
|
|
||||||
2019-01-07 Thomas Koenig <tkoenig@gcc.gnu.org>
|
2019-01-07 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||||
Harald Anlauf <anlauf@gmx.de>
|
Harald Anlauf <anlauf@gmx.de>
|
||||||
Tobias Burnus <burnus@gcc.gnu.org>
|
Tobias Burnus <burnus@gcc.gnu.org>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
// { dg-do compile { target c++11 } }
|
||||||
|
|
||||||
|
constexpr int foo() { thread_local int i __attribute__((unused)) {}; return 1; } // { dg-error "40:.i. declared .thread_local." }
|
||||||
|
|
||||||
|
constexpr int bar() { static int i __attribute__((unused)) {}; return 1; } // { dg-error "34:.i. declared .static." }
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
// { dg-do compile { target c++11 } }
|
||||||
|
|
||||||
|
int foo();
|
||||||
|
|
||||||
|
__thread int i __attribute__((unused)) = foo(); // { dg-error "14:non-local variable .i. declared .__thread. needs" }
|
||||||
|
|
||||||
|
struct S
|
||||||
|
{
|
||||||
|
constexpr S() {}
|
||||||
|
~S();
|
||||||
|
};
|
||||||
|
|
||||||
|
__thread S s __attribute__((unused)); // { dg-error "12:non-local variable .s. declared .__thread. has" }
|
||||||
Loading…
Reference in New Issue