Skip to content

Commit a9d48bb

Browse files
committed
[cppyy] Don't leak deprecation warnings when resolving enum types
Cppyy::ResolveEnum() determines an enum's underlying integer type by JIT-compiling a probe expression of the form: ```c++ std::is_same<unsigned int, std::underlying_type<SomeEnum>::type>::value; ``` If the enum being resolved (or its enclosing scope) is marked deprecated, this purely internal introspection emits a `-Wdeprecated-declarations` warning to stderr. Since cppyy resolves enums while wrapping classes, the warning surfaces in ordinary PyROOT sessions that merely touch a class carrying such an enum. This started breaking a range of roottest tests (which diff process output against reference files) after the historical ESTLType/ESTLtype enum copies in TClassEdit, TDictionary and TStreamerElement were deprecated. Wrap the probe expression in clang diagnostic push/ignored/pop pragmas so that resolving a deprecated enum stays silent. 🤖 Done by AI.
1 parent 0edd975 commit a9d48bb

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

README/ReleaseNotes/v642/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ The following people have contributed to this new version:
4646
* The ROOT **auth** package together with `TVirtualAuth` and `TROOT::GetListOfSecContexts()`, and the **authenticated sockets** (`TSocket::CreateAuthSocket()`) feature are now removed following deprecation in ROOT 6.40.
4747
* The `TSSLSocket` class is now removed following deprecation in ROOT 6.40.
4848
* The bindings to the R programming language that are enabled with the `r=ON` or `tmva-rmva=ON` build options (`TRInterface`, RMVA, and friends) are removed, following deprecation in ROOT 6.40. Their maintenance is no longer justified, given the broader adoption of the scientific Python ecosystem. Users who still rely on R from C++ are encouraged to call R directly via https://cran.r-project.org/package=RInside, which is what the ROOT bindings were using internally.
49+
* Several enums that are redundant with `ROOT::ESTLType` are deprecated and will be removed in ROOT 6.42: `TClassEdit::ESTLType`, `TDictionary::ESTLType`, `TStreamerElement::ESTLType`. Please use `ROOT::ESTLType` instead.
4950

5051
## Python Interface
5152

@@ -83,4 +84,4 @@ If the vectorized backend does not work for a given use case, **please report it
8384

8485
The version of the following packages has been updated:
8586

86-
- xrootd: 5.9.5
87+
- xrootd: 5.9.5

bindings/pyroot/cppyy/cppyy-backend/clingwrapper/src/clingwrapper.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,17 @@ std::string Cppyy::ResolveEnum(const std::string& enum_type)
622622
std::ostringstream decl;
623623
// TODO: now presumed fixed with https://sft.its.cern.ch/jira/browse/ROOT-6988
624624
for (auto& itype : {"unsigned int"}) {
625-
decl << "std::is_same<"
625+
// This is pure type introspection: silence any deprecation warning that
626+
// would otherwise be emitted just because the enum being resolved (or its
627+
// scope) happens to be marked deprecated.
628+
decl << "_Pragma(\"clang diagnostic push\")"
629+
"_Pragma(\"clang diagnostic ignored \\\"-Wdeprecated-declarations\\\"\")"
630+
<< "std::is_same<"
626631
<< itype
627632
<< ", std::underlying_type<"
628633
<< et_short
629-
<< ">::type>::value;";
634+
<< ">::type>::value;"
635+
"_Pragma(\"clang diagnostic pop\")";
630636
if (gInterpreter->ProcessLine(decl.str().c_str())) {
631637
// TODO: "re-sugaring" like this is brittle, but the top
632638
// should be re-translated into AST-based code anyway

0 commit comments

Comments
 (0)