]> granicus.if.org Git - clang/commit
MS ABI: Don't force bases to have an inheritance model
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 8 Aug 2014 00:10:39 +0000 (00:10 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 8 Aug 2014 00:10:39 +0000 (00:10 +0000)
commit4f071e89894b0eef44a22d5cdc68b161fd01de22
treebd429c53b48e8f1a64dd8baa93430729771ff018
parentc137a233c54664d277eb810e5d7aaa2971673d12
MS ABI: Don't force bases to have an inheritance model

Previously, assigning an inheritance model to a derived class would
trigger further assiginments to the various bases of the class.  This
was done to fix a bug where we couldn't handle an implicit
base-to-derived conversion for pointers-to-members when the conversion
was ambiguous at an earlier point.

However, this is not how the MS scheme works.  Instead, assign
inheritance models to *just* the class which owns to declaration we
ended up referencing.

N.B.  This result is surprising in many ways.  It means that it is
possible for a base to have a "larger" inheritance model than it's
derived classes.  It also means that bases in the conversion path do not
get assigned a model.

struct A { void f(); void f(int); };
struct B : A {};
struct C : B {};
void f() { void (C::*x)() = &A::f; }

We can only begin to assign an inheritance model *after* we've seen the
address-of but *before* we've done the implicit conversion the more
derived pointer-to-member type.  After that point, both 'A' and 'C' will
have an inheritance model but 'B' will not.  Surprising, right?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215174 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaType.cpp
test/CodeGenCXX/microsoft-abi-member-pointers.cpp