]> granicus.if.org Git - clang/commit
[ms-cxxabi] Look up operator delete() at every virtual dtor declaration.
authorPeter Collingbourne <peter@pcc.me.uk>
Mon, 20 May 2013 14:12:25 +0000 (14:12 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Mon, 20 May 2013 14:12:25 +0000 (14:12 +0000)
commitf51cfb89b3fe317318e434db4856b06a90afc126
tree593accfcdd0b03c8031fd638c6b04a5acaeaf403
parent26afaf0b121f7c9aec93c3734ea9ebaa8820a7ee
[ms-cxxabi] Look up operator delete() at every virtual dtor declaration.

While the C++ standard requires that this lookup take place only at the
definition point of a virtual destructor (C++11 [class.dtor]p12), the
Microsoft ABI may require the compiler to emit a deleting destructor
for any virtual destructor declared in the TU, including ones without
a body, requiring an operator delete() lookup for every virtual
destructor declaration.  The result of the lookup should be the same
no matter which declaration is used (except in weird corner cases).

This change will cause us to reject some valid TUs in Microsoft ABI
mode, e.g.:

struct A {
  void operator delete(void *);
};

struct B {
  void operator delete(void *);
};

struct C : A, B {
  virtual ~C();
};

As Richard points out, every virtual function declared in a TU
(including this virtual destructor) is odr-used, so it must be defined
in any program which declares it, or the program is ill formed, no
diagnostic required.  Because we know that any definition of this
destructor will cause the lookup to fail, the compiler can choose to
issue a diagnostic here.

Differential Revision: http://llvm-reviews.chandlerc.com/D822

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182270 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/microsoft-dtor-lookup.cpp [new file with mode: 0644]