Skip to content
Snippets Groups Projects
Commit 1b7cfa71 authored by Giuseppe D'Angelo's avatar Giuseppe D'Angelo Committed by Jason Merrill
Browse files

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: default avatarGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: default avatarJason Merrill <jason@redhat.com>
parent 698e0ec8
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment