[llvm-bugs] [Bug 28265] New: Type-dependent explicit destructor call behaves improperly
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jun 22 11:22:52 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28265
Bug ID: 28265
Summary: Type-dependent explicit destructor call behaves
improperly
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: aaron at aaronballman.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
There are two likely-related bugs with explicit destructor calls for a
dependent type. The first bug is that the same diagnostic is trigger multiple
times when it should only be triggered once. The second bug is that the
diagnostic includes a fixit that should not be triggered for dependent types.
Given:
template<typename T>
struct TypeDependent {
void Destruct(T *T1) {
T1->~T(); // No fixit should be suggested because T is type dependent.
}
};
template <typename T>
struct NotTypeDependent {
void Destruct(struct Derived *P) {
P->~Derived(); // It's fine to suggest a fixit because P isn't type
dependent.
}
};
struct Base {
virtual void f() = 0;
};
struct Derived : Base {
virtual void f() override;
};
void f() {
TypeDependent<Derived> BadProblem;
NotTypeDependent<Derived> FineProblem;
BadProblem.Destruct(nullptr);
FineProblem.Destruct(nullptr);
}
E:\llvm\2015>clang -fsyntax-only -Wall -std=c++11 E:\Desktop\ForAaron2.cpp
E:\Desktop\ForAaron2.cpp:4:3: warning: destructor called on non-final 'Derived'
that has virtual functions but
non-virtual destructor [-Wdelete-non-virtual-dtor]
T1->~T(); // No fixit should be suggested because T is type dependent.
^
E:\Desktop\ForAaron2.cpp:27:14: note: in instantiation of member function
'TypeDependent<Derived>::Destruct' requested
here
BadProblem.Destruct(nullptr);
^
E:\Desktop\ForAaron2.cpp:4:8: note: qualify call to silence this warning
T1->~T(); // No fixit should be suggested because T is type dependent.
^
Derived::
E:\Desktop\ForAaron2.cpp:11:5: warning: destructor called on non-final
'Derived' that has virtual functions but
non-virtual destructor [-Wdelete-non-virtual-dtor]
P->~Derived(); // It's fine to suggest a fixit because P isn't type
dependent.
^
E:\Desktop\ForAaron2.cpp:11:8: note: qualify call to silence this warning
P->~Derived(); // It's fine to suggest a fixit because P isn't type
dependent.
^
Derived::
E:\Desktop\ForAaron2.cpp:11:5: warning: destructor called on non-final
'Derived' that has virtual functions but
non-virtual destructor [-Wdelete-non-virtual-dtor]
P->~Derived(); // It's fine to suggest a fixit because P isn't type
dependent.
^
E:\Desktop\ForAaron2.cpp:28:15: note: in instantiation of member function
'NotTypeDependent<Derived>::Destruct'
requested here
FineProblem.Destruct(nullptr);
^
E:\Desktop\ForAaron2.cpp:11:8: note: qualify call to silence this warning
P->~Derived(); // It's fine to suggest a fixit because P isn't type
dependent.
^
Derived::
3 warnings generated.
The dependent case should not recommend T->Derived::~T() as a fixit, and the
non-dependent case should not trigger two diagnostics for the same issue.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160622/7d4b833c/attachment.html>
More information about the llvm-bugs
mailing list