-
- Downloads
c++: introduce __builtin_is_virtual_base_of
P2985R0 (C++26) introduces std::is_virtual_base_of; this is the compiler builtin that will back up the library trait (which strictly requires compiler support). The name has been chosen to match LLVM/MSVC's, as per the discussion here: https://github.com/llvm/llvm-project/issues/98310 The actual user-facing type trait in libstdc++ will be added later. gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): New diagnostic. * cp-trait.def (IS_VIRTUAL_BASE_OF): New builtin. * cp-tree.h (enum base_access_flags): Add a new flag to be able to request a search for a virtual base class. * cxx-pretty-print.cc (pp_cxx_userdef_literal): Update the list of GNU extensions to the grammar. * search.cc (struct lookup_base_data_s): Add a field to request searching for a virtual base class. (dfs_lookup_base): Add the ability to look for a virtual base class. (lookup_base): Forward the flag to dfs_lookup_base. * semantics.cc (trait_expr_value): Implement the builtin by calling lookup_base with the new flag. (finish_trait_expr): Handle the new builtin. gcc/ChangeLog: * doc/extend.texi: Document the new __builtin_is_virtual_base_of builtin; amend the docs for __is_base_of. gcc/testsuite/ChangeLog: * g++.dg/ext/is_virtual_base_of.C: New test. * g++.dg/ext/is_virtual_base_of_diagnostic.C: New test. Signed-off-by:Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by:
Jason Merrill <jason@redhat.com>
Showing
- gcc/cp/constraint.cc 3 additions, 0 deletionsgcc/cp/constraint.cc
- gcc/cp/cp-trait.def 1 addition, 0 deletionsgcc/cp/cp-trait.def
- gcc/cp/cp-tree.h 2 additions, 1 deletiongcc/cp/cp-tree.h
- gcc/cp/cxx-pretty-print.cc 2 additions, 0 deletionsgcc/cp/cxx-pretty-print.cc
- gcc/cp/search.cc 12 additions, 3 deletionsgcc/cp/search.cc
- gcc/cp/semantics.cc 12 additions, 0 deletionsgcc/cp/semantics.cc
- gcc/doc/extend.texi 15 additions, 0 deletionsgcc/doc/extend.texi
- gcc/testsuite/g++.dg/ext/is_virtual_base_of.C 163 additions, 0 deletionsgcc/testsuite/g++.dg/ext/is_virtual_base_of.C
- gcc/testsuite/g++.dg/ext/is_virtual_base_of_diagnostic.C 15 additions, 0 deletionsgcc/testsuite/g++.dg/ext/is_virtual_base_of_diagnostic.C
Loading
Please register or sign in to comment