public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100974] New: [C++23] Implement if consteval
@ 2021-06-08 17:43 jason at gcc dot gnu.org
2021-06-08 17:45 ` [Bug c++/100974] " mpolacek at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2021-06-08 17:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100974
Bug ID: 100974
Summary: [C++23] Implement if consteval
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jason at gcc dot gnu.org
Blocks: 98940
Target Milestone: ---
https://wg21.link/p1938r3
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98940
[Bug 98940] Implement C++23 language features
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/100974] [C++23] Implement if consteval
2021-06-08 17:43 [Bug c++/100974] New: [C++23] Implement if consteval jason at gcc dot gnu.org
@ 2021-06-08 17:45 ` mpolacek at gcc dot gnu.org
2021-06-09 11:58 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-06-08 17:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100974
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2021-06-08
CC| |mpolacek at gcc dot gnu.org
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/100974] [C++23] Implement if consteval
2021-06-08 17:43 [Bug c++/100974] New: [C++23] Implement if consteval jason at gcc dot gnu.org
2021-06-08 17:45 ` [Bug c++/100974] " mpolacek at gcc dot gnu.org
@ 2021-06-09 11:58 ` jakub at gcc dot gnu.org
2021-06-09 14:29 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-06-09 11:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100974
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I have this roughly implemented, adding testcases now.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/100974] [C++23] Implement if consteval
2021-06-08 17:43 [Bug c++/100974] New: [C++23] Implement if consteval jason at gcc dot gnu.org
2021-06-08 17:45 ` [Bug c++/100974] " mpolacek at gcc dot gnu.org
2021-06-09 11:58 ` jakub at gcc dot gnu.org
@ 2021-06-09 14:29 ` jakub at gcc dot gnu.org
2021-06-11 13:53 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-06-09 14:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100974
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50971
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50971&action=edit
gcc12-pr100974.patch
Untested implementation.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/100974] [C++23] Implement if consteval
2021-06-08 17:43 [Bug c++/100974] New: [C++23] Implement if consteval jason at gcc dot gnu.org
` (2 preceding siblings ...)
2021-06-09 14:29 ` jakub at gcc dot gnu.org
@ 2021-06-11 13:53 ` cvs-commit at gcc dot gnu.org
2021-06-11 14:02 ` jakub at gcc dot gnu.org
2021-12-07 19:20 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-11 13:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100974
--- Comment #3 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:117c64266405e244da4dae3ae7b60905af63b955
commit r12-1390-g117c64266405e244da4dae3ae7b60905af63b955
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Jun 11 15:50:34 2021 +0200
c++: Add C++23 consteval if support - P1938R3 [PR100974]
The following patch implements consteval if support.
There is a new IF_STMT_CONSTEVAL_P flag on IF_STMT and IF_COND is
boolean_false_node to match the non-manifestly constant evaluation
behavior, while constexpr evaluation special-cases it. Perhaps cleaner
would be to set the condition to __builtin_is_constant_evaluated () call
but we need the IF_STMT_CONSTEVAL_P flag anyway and the IL would be larger.
And I'm not changing the libstdc++ side, where perhaps we could change
std::is_constant_evaluated definition for
#ifdef __cpp_if_consteval
case to if consteval { return true; } else { return false; }
but we need to keep it defined to __builtin_is_constant_evaluated ()
for C++20 or older.
2021-06-11 Jakub Jelinek <jakub@redhat.com>
PR c++/100974
gcc/c-family/
* c-cppbuiltin.c (c_cpp_builtins): Predefine __cpp_if_consteval for
-std=c++2b for P1938R3 consteval if support.
gcc/cp/
* cp-tree.h (struct saved_scope): Add consteval_if_p
member. Formatting fix for the discarded_stmt comment.
(in_consteval_if_p, IF_STMT_CONSTEVAL_P): Define.
* parser.c (cp_parser_lambda_expression): Temporarily disable
in_consteval_if_p when parsing lambda body.
(cp_parser_selection_statement): Parse consteval if.
* decl.c (struct named_label_entry): Add in_consteval_if member.
(level_for_consteval_if): New function.
(poplevel_named_label_1, check_previous_goto_1, check_goto): Handle
consteval if.
* constexpr.c (cxx_eval_builtin_function_call): Clarify in comment
why CP_BUILT_IN_IS_CONSTANT_EVALUATED needs to *non_constant_p
for !ctx->manifestly_const_eval.
(cxx_eval_conditional_expression): For IF_STMT_CONSTEVAL_P evaluate
condition as if it was __builtin_is_constant_evaluated call.
(potential_constant_expression_1): For IF_STMT_CONSTEVAL_P always
recurse on both branches.
* cp-gimplify.c (genericize_if_stmt): Genericize
IF_STMT_CONSTEVAL_P
as the else branch.
* pt.c (tsubst_expr) <case IF_STMT>: Copy IF_STMT_CONSTEVAL_P.
Temporarily set in_consteval_if_p when recursing on
IF_STMT_CONSTEVAL_P then branch.
(tsubst_lambda_expr): Temporarily disable
in_consteval_if_p when instantiating lambda body.
* call.c (immediate_invocation_p): Return false when
in_consteval_if_p.
gcc/testsuite/
* g++.dg/cpp23/consteval-if1.C: New test.
* g++.dg/cpp23/consteval-if2.C: New test.
* g++.dg/cpp23/consteval-if3.C: New test.
* g++.dg/cpp23/consteval-if4.C: New test.
* g++.dg/cpp23/consteval-if5.C: New test.
* g++.dg/cpp23/consteval-if6.C: New test.
* g++.dg/cpp23/consteval-if7.C: New test.
* g++.dg/cpp23/consteval-if8.C: New test.
* g++.dg/cpp23/consteval-if9.C: New test.
* g++.dg/cpp23/consteval-if10.C: New test.
* g++.dg/cpp23/feat-cxx2b.C: Add __cpp_if_consteval tests.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/100974] [C++23] Implement if consteval
2021-06-08 17:43 [Bug c++/100974] New: [C++23] Implement if consteval jason at gcc dot gnu.org
` (3 preceding siblings ...)
2021-06-11 13:53 ` cvs-commit at gcc dot gnu.org
@ 2021-06-11 14:02 ` jakub at gcc dot gnu.org
2021-12-07 19:20 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-06-11 14:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100974
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Implemented for GCC 12.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/100974] [C++23] Implement if consteval
2021-06-08 17:43 [Bug c++/100974] New: [C++23] Implement if consteval jason at gcc dot gnu.org
` (4 preceding siblings ...)
2021-06-11 14:02 ` jakub at gcc dot gnu.org
@ 2021-12-07 19:20 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-07 19:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100974
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gonzalo.gadeschi at gmail dot com
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 79452 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-12-07 19:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 17:43 [Bug c++/100974] New: [C++23] Implement if consteval jason at gcc dot gnu.org
2021-06-08 17:45 ` [Bug c++/100974] " mpolacek at gcc dot gnu.org
2021-06-09 11:58 ` jakub at gcc dot gnu.org
2021-06-09 14:29 ` jakub at gcc dot gnu.org
2021-06-11 13:53 ` cvs-commit at gcc dot gnu.org
2021-06-11 14:02 ` jakub at gcc dot gnu.org
2021-12-07 19:20 ` pinskia 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).