]> gcc.gnu.org Git - gcc.git/commit
c++: extern thread_local declarations in constexpr [PR104994]
authorJakub Jelinek <jakub@redhat.com>
Thu, 24 Mar 2022 09:12:25 +0000 (10:12 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 24 Mar 2022 09:12:25 +0000 (10:12 +0100)
commit72124f487ccb5c8065dd5f7b8fba254600b7e611
tree8de82fe3cbd553d06bbcba957c4685e2a51f5a3e
parent497bde3ab92b2c292f78672db341bbb7cc1bcf1f
c++: extern thread_local declarations in constexpr [PR104994]

C++14 to C++20 apparently should allow extern thread_local declarations in
constexpr functions, however useless they are there (because accessing
such vars is not valid in a constant expression, perhaps sizeof/decltype).
P2242 changed that for C++23 to passing through declaration but
https://cplusplus.github.io/CWG/issues/2552.html
has been filed for it yesterday.

The following patch implements the proposed wording of CWG 2552 in addition
to fixing the C++14 - C++20 handling bug.
If you'd like instead to keep the current pedantic C++23 wording for now,
that would mean taking out the first hunk (cxx_eval_constant_expression) and
g++.dg/cpp23/constexpr-nonlit2.C hunk.

2022-03-24  Jakub Jelinek  <jakub@redhat.com>

PR c++/104994
* constexpr.cc (cxx_eval_constant_expression): Don't diagnose passing
through extern thread_local declarations.  Change wording from
declaration to definition.
(potential_constant_expression_1): Don't diagnose extern thread_local
declarations.  Change wording from declared to defined.
* decl.cc (start_decl): Likewise.

* g++.dg/diagnostic/constexpr1.C: Change expected diagnostic wording
from declared to defined.
* g++.dg/cpp23/constexpr-nonlit1.C: Likewise.
(garply): Change dg-error into dg-bogus.
* g++.dg/cpp23/constexpr-nonlit2.C: Change expected diagnostic wording
from declaration to definition.
* g++.dg/cpp23/constexpr-nonlit6.C: Change expected diagnostic wording
from declared to defined.
* g++.dg/cpp23/constexpr-nonlit7.C: New test.
* g++.dg/cpp2a/constexpr-try5.C: Change expected diagnostic wording
from declared to defined.
* g++.dg/cpp2a/consteval3.C: Likewise.
gcc/cp/constexpr.cc
gcc/cp/decl.cc
gcc/testsuite/g++.dg/cpp23/constexpr-nonlit1.C
gcc/testsuite/g++.dg/cpp23/constexpr-nonlit2.C
gcc/testsuite/g++.dg/cpp23/constexpr-nonlit6.C
gcc/testsuite/g++.dg/cpp23/constexpr-nonlit7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/consteval3.C
gcc/testsuite/g++.dg/cpp2a/constexpr-try5.C
gcc/testsuite/g++.dg/diagnostic/constexpr1.C
This page took 0.063117 seconds and 6 git commands to generate.