diff mbox series

[C++] Add test for c++/67533 (or not?)

Message ID 20190609233749.GB5989@redhat.com
State New
Headers show
Series [C++] Add test for c++/67533 (or not?) | expand

Commit Message

Marek Polacek June 9, 2019, 11:37 p.m. UTC
This testcase used to ICE but was fixed by r259067.  We now issue

67533.C:5:26: error: conversion from ‘void’ to non-scalar type ‘Tls’ requested
    5 | thread_local Tls mytls = mytls; // { dg-error "" }
      |                          ^~~~~

whereas clang++ and icc compile it.  However, the test uses a reserved identifier
([lex.name]/3), and I think the error is fine.

Do you think it's worth adding this test?  I thought so, just to check we don't
ICE, but who uses a mangled name as an identifier?!

Tested x86_64-linux, ok for trunk?

2019-06-09  Marek Polacek  <polacek@redhat.com>

	PR c++/67533
	* g++.dg/tls/thread_local-ice5.C: New test.

Comments

Jason Merrill June 12, 2019, 8:15 p.m. UTC | #1
On 6/9/19 7:37 PM, Marek Polacek wrote:
> This testcase used to ICE but was fixed by r259067.  We now issue
> 
> 67533.C:5:26: error: conversion from ‘void’ to non-scalar type ‘Tls’ requested
>      5 | thread_local Tls mytls = mytls; // { dg-error "" }
>        |                          ^~~~~
> 
> whereas clang++ and icc compile it.  However, the test uses a reserved identifier
> ([lex.name]/3), and I think the error is fine.

> Do you think it's worth adding this test?  I thought so, just to check we don't
> ICE, but who uses a mangled name as an identifier?!

OK.

I suppose get_tls_wrapper_fn could check whether a previous declaration 
has the right type, to give a more helpful diagnostic.

The original testcase makes me wonder if we should be marking 
compiler-generated  functions as no_instrument_function.

Jason
diff mbox series

Patch

diff --git gcc/testsuite/g++.dg/tls/thread_local-ice5.C gcc/testsuite/g++.dg/tls/thread_local-ice5.C
new file mode 100644
index 00000000000..4147c322e7b
--- /dev/null
+++ gcc/testsuite/g++.dg/tls/thread_local-ice5.C
@@ -0,0 +1,7 @@ 
+// PR c++/67533
+// { dg-do compile { target c++11 } }
+// { dg-require-effective-target tls }
+
+struct Tls {};
+void _ZTW5mytls();
+thread_local Tls mytls = mytls; // { dg-error "" }