New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-Wundefined-func-template
warns that no definition is available for a pure virtual function
#74016
Comments
@llvm/issue-subscribers-clang-frontend Author: Akira Hatanaka (ahatanak)
The warning seems incorrect as `B::bar` is pure virtual and its definition isn't needed.
$ cat test.cpp
$ clang++ -std=c++20 test.cpp -Wundefined-func-template -c |
Confirmed: https://godbolt.org/z/6a3vvveEG |
Hi! This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below. |
@llvm/issue-subscribers-good-first-issue Author: Akira Hatanaka (ahatanak)
The warning seems incorrect as `B::bar` is pure virtual and its definition isn't needed.
$ cat test.cpp
$ clang++ -std=c++20 test.cpp -Wundefined-func-template -c |
I'd like to pick this up. I'm sharing my thoughts so we can discuss them. Where does this happen? The warning is coming from llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp Lines 4954 to 4958 in bc51a36
We do not check if the function is a pure virtual function via Issue fix IMO we should just add another condition in the if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
!getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc()) &&
!Function->isVirtualAsWritten()) { ... } Finally we should add a test-case for this under clang/test/SemaTemplate/ called if all these sound good, I'll start implementing it. |
Sounds about right/plausible to me, thanks! |
We still want to emit the warning if The patch silences the warning. |
Sorry I didn't get this. Are we talking about the following? constexpr void foo(const T &) { B::bar(1); } instead of: constexpr void foo(const T &) { bar(1); } |
Yes, that's what I meant. |
This is what we get with the patch:
|
I meant the patch was silencing the Note that ToT clang emits the warning for the following code, but with the patch, it doesn't emit any warnings:
|
Warning '-Wundefined-func-template' incorrectly indicates that no definition is available for a pure virtual function. However, a definition is not needed for a pure virtual function. Fixes llvm#74016 Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Thanks for pinging me about this @ahatanak. I revisited the patch based on your recommendation (thanks) and added a test case for it. |
Warning '-Wundefined-func-template' incorrectly indicates that no definition is available for a pure virtual function. However, a definition is not needed for a pure virtual function. Fixes llvm#74016 Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Warning '-Wundefined-func-template' incorrectly indicates that no definition is available for a pure virtual function. However, a definition is not needed for a pure virtual function. Fixes llvm#74016 Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Warning '-Wundefined-func-template' incorrectly indicates that no definition is available for a pure virtual function. However, a definition is not needed for a pure virtual function. Fixes llvm#74016 Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Warning '-Wundefined-func-template' incorrectly indicates that no definition is available for a pure virtual function. However, a definition is not needed for a pure virtual function. Fixes llvm#74016 Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Warning '-Wundefined-func-template' incorrectly indicates that no definition is available for a pure virtual function. However, a definition is not needed for a pure virtual function. Fixes llvm#74016 Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
…lvm#74510) Warning '-Wundefined-func-template' incorrectly indicates that no definition is available for a pure virtual function. However, a definition is not needed for a pure virtual function. Fixes llvm#74016 (cherry picked from commit 0c92f86) Conflicts: clang/docs/ReleaseNotes.rst
The warning seems incorrect as
B::bar
is pure virtual and its definition isn't needed.The text was updated successfully, but these errors were encountered: