aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2019-01-07 22:28:30 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2019-01-07 22:28:30 +0000
commit2c86a5741f00f3a85ccd685f250070013c67fc90 (patch)
treeb42c429e5b3f75358238d7a4938ff19cd6b33c2e /gcc
parent33a5d8ccb5482e446410ffbba30f0b560fc1c8fc (diff)
downloadgcc-2c86a5741f00f3a85ccd685f250070013c67fc90.zip
gcc-2c86a5741f00f3a85ccd685f250070013c67fc90.tar.gz
gcc-2c86a5741f00f3a85ccd685f250070013c67fc90.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c22
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/constexpr1.C5
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/thread1.C13
5 files changed, 40 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5267b9d..4da1c82 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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>
PR c++/88741 - wrong error with initializer-string.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 1fc7a1a..220a95c 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5235,10 +5235,12 @@ start_decl (const cp_declarator *declarator,
{
bool ok = false;
if (CP_DECL_THREAD_LOCAL_P (decl))
- error ("%qD declared %<thread_local%> in %<constexpr%> function",
- decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qD declared %<thread_local%> in %<constexpr%> function",
+ 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
ok = true;
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)
&& !DECL_FUNCTION_SCOPE_P (decl))
{
+ location_t dloc = DECL_SOURCE_LOCATION (decl);
if (init)
- error ("non-local variable %qD declared %<__thread%> "
- "needs dynamic initialization", decl);
+ error_at (dloc, "non-local variable %qD declared %<__thread%> "
+ "needs dynamic initialization", decl);
else
- error ("non-local variable %qD declared %<__thread%> "
- "has a non-trivial destructor", decl);
+ error_at (dloc, "non-local variable %qD declared %<__thread%> "
+ "has a non-trivial destructor", decl);
static bool informed;
if (!informed)
{
- inform (DECL_SOURCE_LOCATION (decl),
- "C++11 %<thread_local%> allows dynamic initialization "
- "and destruction");
+ inform (dloc, "C++11 %<thread_local%> allows dynamic "
+ "initialization and destruction");
informed = true;
}
return;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f512ed1..29b3b83 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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>
Harald Anlauf <anlauf@gmx.de>
Tobias Burnus <burnus@gcc.gnu.org>
diff --git a/gcc/testsuite/g++.dg/diagnostic/constexpr1.C b/gcc/testsuite/g++.dg/diagnostic/constexpr1.C
new file mode 100644
index 0000000..f029e86
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/constexpr1.C
@@ -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." }
diff --git a/gcc/testsuite/g++.dg/diagnostic/thread1.C b/gcc/testsuite/g++.dg/diagnostic/thread1.C
new file mode 100644
index 0000000..a35d997
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/thread1.C
@@ -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" }