public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] Fix four more locations
@ 2019-01-07 17:08 Paolo Carlini
  2019-01-07 19:21 ` Jason Merrill
  2019-01-08 10:25 ` Christophe Lyon
  0 siblings, 2 replies; 4+ messages in thread
From: Paolo Carlini @ 2019-01-07 17:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 112 bytes --]

Hi,

should be straightforward material. Tested x86_64-linux, as usual.

Thanks, Paolo.

/////////////////////


[-- Attachment #2: CL_locs_20 --]
[-- Type: text/plain, Size: 297 bytes --]

/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.

[-- Attachment #3: patch_locs_20 --]
[-- Type: text/plain, Size: 2855 bytes --]

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 267651)
+++ cp/decl.c	(working copy)
@@ -5235,10 +5236,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 +8256,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;
Index: testsuite/g++.dg/diagnostic/constexpr1.C
===================================================================
--- testsuite/g++.dg/diagnostic/constexpr1.C	(nonexistent)
+++ testsuite/g++.dg/diagnostic/constexpr1.C	(working copy)
@@ -0,0 +1,5 @@
+// { dg-do compile { target c++11 } }
+
+constexpr void foo() { thread_local int i __attribute__((unused)) {}; }  // { dg-error "41:.i. declared .thread_local." }
+
+constexpr void bar() { static int i __attribute__((unused)) {}; }  // { dg-error "35:.i. declared .static." }
Index: testsuite/g++.dg/diagnostic/thread1.C
===================================================================
--- testsuite/g++.dg/diagnostic/thread1.C	(nonexistent)
+++ testsuite/g++.dg/diagnostic/thread1.C	(working copy)
@@ -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" }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ Patch] Fix four more locations
  2019-01-07 17:08 [C++ Patch] Fix four more locations Paolo Carlini
@ 2019-01-07 19:21 ` Jason Merrill
  2019-01-08 10:25 ` Christophe Lyon
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2019-01-07 19:21 UTC (permalink / raw)
  To: Paolo Carlini, gcc-patches

OK.

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ Patch] Fix four more locations
  2019-01-07 17:08 [C++ Patch] Fix four more locations Paolo Carlini
  2019-01-07 19:21 ` Jason Merrill
@ 2019-01-08 10:25 ` Christophe Lyon
  2019-01-08 11:49   ` Paolo Carlini
  1 sibling, 1 reply; 4+ messages in thread
From: Christophe Lyon @ 2019-01-08 10:25 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill, Paolo Carlini

On Mon, 7 Jan 2019 at 18:08, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>
> Hi,
>
> should be straightforward material. Tested x86_64-linux, as usual.
>
> Thanks, Paolo.
>
> /////////////////////
>

Hi,

The new g++.dg/diagnostic/thread1.C passes on aarch64, but fails on arm:
FAIL: g++.dg/diagnostic/thread1.C  -std=c++14  (test for errors, line 13)
FAIL: g++.dg/diagnostic/thread1.C  -std=c++14 (test for excess errors)
FAIL: g++.dg/diagnostic/thread1.C  -std=c++17  (test for errors, line 13)
FAIL: g++.dg/diagnostic/thread1.C  -std=c++17 (test for excess errors)

the logs say:
/gcc/testsuite/g++.dg/diagnostic/thread1.C:13:12: error: non-local
variable 's' declared '__thread' needs dynamic initialization

I don't know why the error message does not match?

Christophe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ Patch] Fix four more locations
  2019-01-08 10:25 ` Christophe Lyon
@ 2019-01-08 11:49   ` Paolo Carlini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Carlini @ 2019-01-08 11:49 UTC (permalink / raw)
  To: Christophe Lyon, gcc-patches; +Cc: Jason Merrill

Hi,

On 08/01/19 11:24, Christophe Lyon wrote:
> On Mon, 7 Jan 2019 at 18:08, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>> Hi,
>>
>> should be straightforward material. Tested x86_64-linux, as usual.
>>
>> Thanks, Paolo.
>>
>> /////////////////////
>>
> Hi,
>
> The new g++.dg/diagnostic/thread1.C passes on aarch64, but fails on arm:
> FAIL: g++.dg/diagnostic/thread1.C  -std=c++14  (test for errors, line 13)
> FAIL: g++.dg/diagnostic/thread1.C  -std=c++14 (test for excess errors)
> FAIL: g++.dg/diagnostic/thread1.C  -std=c++17  (test for errors, line 13)
> FAIL: g++.dg/diagnostic/thread1.C  -std=c++17 (test for excess errors)
>
> the logs say:
> /gcc/testsuite/g++.dg/diagnostic/thread1.C:13:12: error: non-local
> variable 's' declared '__thread' needs dynamic initialization
>
> I don't know why the error message does not match?

Evidently on some targets that variable also needs dynamic 
initialization, the issue isn't just that it has a non-trivial 
destructor. Thus, I'm simply going to shorten by one word the expected 
string.

Thanks, Paolo.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-08 11:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 17:08 [C++ Patch] Fix four more locations Paolo Carlini
2019-01-07 19:21 ` Jason Merrill
2019-01-08 10:25 ` Christophe Lyon
2019-01-08 11:49   ` Paolo Carlini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).