[tcling] Suppress -Wunused-result diagnostics in wrappers generated by TClingCallFunc#9244
Conversation
|
Starting build on |
vepadulano
left a comment
There was a problem hiding this comment.
LGTM, thanks for finding this out it !
|
Would changing to also fix it? (I can't judge if that's a better or worse solution :) ) |
|
I think Enrico's solution might be slight better as it is a more local solution (and clarify the intent of the code). |
dd5fb59 to
2ea6e72
Compare
|
Starting build on |
-Wunused-result diagnostics in wrappers generated by TClingCallFunc-Wunused-result diagnostics in wrappers generated by TClingCallFunc
Yes, of course. Changed! Thanks for the suggestion, @eguiraud! |
|
Build failed on mac11.0/cxx17. Failing tests: |
vgvassilev
left a comment
There was a problem hiding this comment.
Can we get a test for this, presumably in https://github.com/root-project/root/blob/master/core/metacling/test/TClingCallFuncTests.cxx
|
Build failed on windows10/cxx14. Warnings:
Failing tests: |
…y TClingCallFunc
A TClingCallFunc wrapper function might look as the excerpt below, where the
function denoted by `func` may have been annotated as `[[nodiscard]]`. Note that
if `ret == nullptr` the result of the call is unused.
```
extern "C" void __cf_0(void* obj, int nargs, void** args, void* ret) {
if (ret) {
new (ret) (return_type) ((class_name*)obj)->func(args...);
}
else {
((class_name*)obj)->func(args...);
}
}
```
In turn, this triggers warnings when used by cppyy/PyROOT, e.g.
```
>>> import ROOT
>>> v = ROOT.std.vector(int)()
>>> v.empty()
input_line_34:10:7: warning: ignoring return value of function declared with 'nodiscard' attribute
[-Wunused-result]
((const vector<int>*)obj)->empty();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
True
>>>
```
Given the above, the second call expression will be casted to `void`.
Closes issue root-project#8622.
2ea6e72 to
6368084
Compare
|
Starting build on |
|
Build failed on ROOT-ubuntu16/nortcxxmod. Errors:
|
6368084 to
2e96179
Compare
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
|
Starting build on |
|
Build failed on ROOT-ubuntu16/nortcxxmod. Errors:
|
|
Build failed on ROOT-ubuntu2004/soversion. Errors:
|
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
|
Build failed on ROOT-performance-centos8-multicore/default. Errors:
|
2e96179 to
8993573
Compare
|
Starting build on |
|
Build failed on mac11.0/cxx17. Failing tests: |
|
Build failed on windows10/cxx14. Failing tests: |
8993573 to
bd11bfe
Compare
|
Starting build on |
bd11bfe to
5dfb0c7
Compare
|
Starting build on |
|
Build failed on windows10/cxx14. Errors:
|
5dfb0c7 to
f216f65
Compare
|
Starting build on |
|
Build failed on mac11.0/cxx17. Failing tests: |
This pull-request suppresses
-Wunused-resultdiagnostics for wrapper functions generated by TClingCallFunc (see below).A TClingCallFunc wrapper function might look as the excerpt below, where the function denoted by
funcmay have been annotated as[[nodiscard]]. Note that ifret == nullptrthe result of the call is unused.In turn, this triggers warnings when used by cppyy/PyROOT, e.g.
Changes or fixes:
-Wunused-resultdiagnostics only for TClingCallFunc wrapper functions.Checklist:
This PR fixes #8622.
Sibling PR in roottest: root-project/roottest#791