[RFC PATCH] testsuite: Add plugin to verify bits/std.cc exports

Nathaniel Shead nathanieloshead@gmail.com
Sat Mar 21 08:10:41 GMT 2026


On Thu, Mar 19, 2026 at 04:54:13PM +0100, Jakub Jelinek wrote:
> On Thu, Mar 19, 2026 at 04:08:23PM +0100, Tomasz Kaminski wrote:
> > > > The following patch adds another g++.dg/plugin/ testsuite plugin,
> > > > this time to verify whether some std.cc exports aren't mistakenly
> > > > omitted.  The patch is on top of the uglification plugin patch,
> > > > but only dependent on it because of the plugin_test_list hunk,
> > > > it could be applied independently with a little effort.
> > > >
> > > > The patch is a reworked version of the
> > > > https://gcc.gnu.org/pipermail/libstdc++/2025-August/thread.html#62859
> > > > proof of concept.  That version just dumped out everything it saw
> > > > in the std namespace and its child namespaces (excluding non-inline
> > > > subnamespaces with identifiers starting with underscore) and then I've
> > > > used sed&grep to form a list of omissions.
> > > >
> > > > This patch keeps the previous walk of std namespace and namespaces
> > > children
> > > > of it, but it only reports (in this version using error_at instead of
> > > inform
> > > > previously) what it finds if it isn't exported from the module and is not
> > > > deprecated (deprecated attribute is used usually for zombie.names in the
> > > > standard).
> > >
> > One option is to put the in std.compat module only. It will fit the idea
> > for this module,
> > to provide more compatible replacement for modules.
> 
> Note, the plugin will not really work on std.compat, unlike std that has
> export import std;
> and that means the DECL_NAMESPACE_BINDINGS will be full of BINDING_VECTOR
> elts and I have no idea what they mean and how to handle those.
> 
> 	Jakub
> 

A BINDING_VECTOR is a mapping from a module to the declarations provided
by that module.  There's also a few "fixed" binding slots at the start,
for declarations provided by the current module, and then some slots
for merging global-module or partition declarations that shouldn't be
used by name lookup.  (This should probably be documented more clearly
in cp-tree.def, I might make a patch for that if I get a chance.)

I recently added a 'walk_namespace_bindings' helper for use by
reflection which will handle walking any BINDING_VECTORs and pulling out
just the visible declarations; I don't think that can be used directly
by this plugin because I guess you need to know whether the declarations
have come from 'export import' or not, which is not easy without seeing
whether they came from BINDING_SLOT_CURRENT vs. one of the imported
bindings, or both, but it could be adjusted for this purpose. 

(Note DECL_MODULE_IMPORT_P will not be set if the declaration also came
from a header in the current TU, and DECL_MODULE_ENTITY_P will be set
even if the declaration was not visible from the import and only came
due to being a dependency.)

Yours,
Nathaniel


More information about the Libstdc++ mailing list