While testing the ATLAS build against root 6.14.02, i ran into some issues
with how cling handles forward declarations of enums. I've managed
to put together a standalone reproducer, which is attached.
To demonstrate on lxplus:
This type defines an enum in a namespace:
which is used by two modules. In the first module, it's used
only in passing:
while in the second module, we select a template type that uses the enum:
If we load (in a way that triggers autoparsing) in order the first module
followed by the second, we get errors:
The forward declaration code here is indeed what's embededed in the C++ module
written by genreflex.
I see at least two issues related to the forward declaration of the enum here.
First, the forward declaration includes a base type, while the original
declaration does not. This is what actually causes the observed error.
However, i also noticed that TCling::RegisterModule contains code to
remove from the forward declarations any enums that have already been defined.
In principle, this should have avoided the error that we see here.
But the code in RegisterModule does not properly handle enums in namespaces.
It assumes that the forward declaration code will have the namespace
specifies on separate lines, like:
However, genreflex is actually all on a single line, which causes the code
in RegisterModule to fail completely.
One can avoid this error by adding an explicit base type to the enum,
which is what i did for the ATLAS code that first provoked this error.