public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102612] New: [C++23] P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions
@ 2021-10-05 16:24 mpolacek at gcc dot gnu.org
2021-10-05 16:26 ` [Bug c++/102612] " mpolacek at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-10-05 16:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102612
Bug ID: 102612
Summary: [C++23] P2242R3 - Non-literal variables (and labels
and gotos) in constexpr functions
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
See https://wg21.link/p2242r3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102612] [C++23] P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions
2021-10-05 16:24 [Bug c++/102612] New: [C++23] P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions mpolacek at gcc dot gnu.org
@ 2021-10-05 16:26 ` mpolacek at gcc dot gnu.org
2021-10-06 8:30 ` cvs-commit at gcc dot gnu.org
2021-10-06 9:12 ` jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-10-05 16:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102612
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Last reconfirmed| |2021-10-05
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2021-October/580960.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102612] [C++23] P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions
2021-10-05 16:24 [Bug c++/102612] New: [C++23] P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions mpolacek at gcc dot gnu.org
2021-10-05 16:26 ` [Bug c++/102612] " mpolacek at gcc dot gnu.org
@ 2021-10-06 8:30 ` cvs-commit at gcc dot gnu.org
2021-10-06 9:12 ` jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-06 8:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102612
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:8892d532d66910e518bc135a851a104322385ca2
commit r12-4206-g8892d532d66910e518bc135a851a104322385ca2
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Oct 6 10:28:31 2021 +0200
c++: Implement C++23 P2242R3 - Non-literal variables (and labels and gotos)
in constexpr functions [PR102612]
The following patch implements C++23 P2242R3 - Non-literal variables
(and labels and gotos) in constexpr functions.
I think it is mostly straightforward, don't diagnose certain
statements/declarations just because of their presence in
constexpr/consteval functions, but (except for the non-literal type
var declarations which ought to be caught by e.g. constructor or
destructor call during evaluation not being constexpr and for
labels which are now always allowed) diagnose it during constexpr
evaluation.
2021-10-06 Jakub Jelinek <jakub@redhat.com>
PR c++/102612
gcc/c-family/
* c-cppbuiltin.c (c_cpp_builtins): For -std=c++23 predefine
__cpp_constexpr to 202110L rather than 201907L.
gcc/cp/
* parser.c (cp_parser_jump_statement): Implement C++23 P2242R3.
Allow goto expressions in constexpr function bodies for C++23.
Adjust error message for older standards to mention it.
* decl.c (start_decl): Allow static and thread_local declarations
in constexpr function bodies for C++23. Adjust error message for
older standards to mention it.
* constexpr.c (ensure_literal_type_for_constexpr_object): Allow
declarations of variables with non-literal type in constexpr
function
bodies for C++23. Adjust error message for older standards to
mention
it.
(cxx_eval_constant_expression) <case DECL_EXPR>: Diagnose
declarations
of initialization of static or thread_local vars.
(cxx_eval_constant_expression) <case GOTO_EXPR>: Diagnose goto
statements for C++23.
(potential_constant_expression_1) <case DECL_EXPR>: Swap the
CP_DECL_THREAD_LOCAL_P and TREE_STATIC checks.
(potential_constant_expression_1) <case LABEL_EXPR>: Allow labels
for
C++23. Adjust error message for older standards to mention it.
gcc/testsuite/
* g++.dg/cpp23/feat-cxx2b.C: Expect __cpp_constexpr 202110L rather
than 201907L.
* g++.dg/cpp23/constexpr-nonlit1.C: New test.
* g++.dg/cpp23/constexpr-nonlit2.C: New test.
* g++.dg/cpp23/constexpr-nonlit3.C: New test.
* g++.dg/cpp23/constexpr-nonlit4.C: New test.
* g++.dg/cpp23/constexpr-nonlit5.C: New test.
* g++.dg/cpp23/constexpr-nonlit6.C: New test.
* g++.dg/diagnostic/constexpr1.C: Only expect some diagnostics for
c++20_down.
* g++.dg/cpp1y/constexpr-label.C: Likewise.
* g++.dg/cpp1y/constexpr-neg1.C: Likewise.
* g++.dg/cpp2a/constexpr-try5.C: Likewise. Adjust some expected
wording.
* g++.dg/cpp2a/constexpr-dtor3.C: Likewise.
* g++.dg/cpp2a/consteval3.C: Likewise. Add effective target c++20
and remove dg-options.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102612] [C++23] P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions
2021-10-05 16:24 [Bug c++/102612] New: [C++23] P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions mpolacek at gcc dot gnu.org
2021-10-05 16:26 ` [Bug c++/102612] " mpolacek at gcc dot gnu.org
2021-10-06 8:30 ` cvs-commit at gcc dot gnu.org
@ 2021-10-06 9:12 ` jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-10-06 9:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102612
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Implemented for GCC 12.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-06 9:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 16:24 [Bug c++/102612] New: [C++23] P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions mpolacek at gcc dot gnu.org
2021-10-05 16:26 ` [Bug c++/102612] " mpolacek at gcc dot gnu.org
2021-10-06 8:30 ` cvs-commit at gcc dot gnu.org
2021-10-06 9:12 ` jakub at gcc dot gnu.org
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).