aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-06-24 20:46:09 -0400
committerJason Merrill <jason@redhat.com>2020-07-02 13:20:23 -0400
commite6321c4508b2a85c21246c1c06a8208e2a151e48 (patch)
tree7185013f41363425d08894d5e1704a3c3d6e7025 /gcc/c-family
parent105ecbea5f402713130fef4d41bb000e2d23493b (diff)
downloadgcc-e6321c4508b2a85c21246c1c06a8208e2a151e48.zip
gcc-e6321c4508b2a85c21246c1c06a8208e2a151e48.tar.gz
gcc-e6321c4508b2a85c21246c1c06a8208e2a151e48.tar.bz2
c++: Support C++20 virtual consteval functions. [PR88335]
Jakub's partial implementation of consteval virtual had trouble with the current ABI requirement that we omit the vtable slot for a consteval virtual function; it's difficult to use the normal code for constant evaluation and also magically make the slots disappear if the vtables get written out. I notice that Clang trunk also doesn't implement that requirement, and it seems unnecessary to me; I expect consteval virtual functions to be extremely rare, so it should be fine to just give them a vtable slot as normal but put zero in it if the vtable gets emitted. I've commented as much to the ABI committee. One of Jakub's testcases points out that we weren't handling thunks in our constexpr virtual handling; that is fixed here as well. Incidentally, being able to use C++11 range-for definitely simplified clear_consteval_vfns. gcc/c-family/ChangeLog: * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_consteval. gcc/cp/ChangeLog: * decl.c (grokfndecl): Allow consteval virtual. * search.c (check_final_overrider): Check consteval mismatch. * constexpr.c (cxx_eval_thunk_call): New. (cxx_eval_call_expression): Call it. * cvt.c (cp_get_fndecl_from_callee): Handle FDESC_EXPR. * decl2.c (mark_vtable_entries): Track vtables with consteval. (maybe_emit_vtables): Pass consteval_vtables through. (clear_consteval_vfns): Replace consteval with nullptr. (c_parse_final_cleanups): Call it. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/consteval-virtual1.C: New test. * g++.dg/cpp2a/consteval-virtual2.C: New test. * g++.dg/cpp2a/consteval-virtual3.C: New test. * g++.dg/cpp2a/consteval-virtual4.C: New test. * g++.dg/cpp2a/consteval-virtual5.C: New test. Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-cppbuiltin.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index a7d65d6..83f52fd 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -995,7 +995,7 @@ c_cpp_builtins (cpp_reader *pfile)
cpp_define (pfile, "__cpp_constexpr=201907L");
cpp_define (pfile, "__cpp_constexpr_in_decltype=201711L");
cpp_define (pfile, "__cpp_conditional_explicit=201806L");
- /* cpp_define (pfile, "__cpp_consteval=201811L"); */
+ cpp_define (pfile, "__cpp_consteval=201811L");
cpp_define (pfile, "__cpp_constinit=201907L");
cpp_define (pfile, "__cpp_deduction_guides=201907L");
cpp_define (pfile, "__cpp_nontype_template_parameter_class=201806L");