Nice! It wasn't even a bug in MS ABI code. :)
On Thu, Jan 16, 2014 at 4:02 AM, David Majnemer <[email protected]>wrote: > Author: majnemer > Date: Thu Jan 16 06:02:55 2014 > New Revision: 199374 > > URL: http://llvm.org/viewvc/llvm-project?rev=199374&view=rev > Log: > Sema: Fix crash during member pointer conversion involving incomplete > classes > > We would attempt to determine the inheritance relationship between > classes 'A' and 'B' during static_cast if we tried to convert from 'int > A::*' to 'int B::*'. However, the question "does A derive from B" is > not meaningful when 'A' isn't defined. > > Handle this case by requiring that 'A' be defined. > > This fixes PR18506. > > Modified: > cfe/trunk/lib/Sema/SemaCast.cpp > cfe/trunk/test/SemaCXX/static-cast.cpp > > Modified: cfe/trunk/lib/Sema/SemaCast.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=199374&r1=199373&r2=199374&view=diff > > ============================================================================== > --- cfe/trunk/lib/Sema/SemaCast.cpp (original) > +++ cfe/trunk/lib/Sema/SemaCast.cpp Thu Jan 16 06:02:55 2014 > @@ -1346,7 +1346,8 @@ TryStaticMemberPointerUpcast(Sema &Self, > QualType DestClass(DestMemPtr->getClass(), 0); > CXXBasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/true, > /*DetectVirtual=*/true); > - if (!Self.IsDerivedFrom(SrcClass, DestClass, Paths)) { > + if (Self.RequireCompleteType(OpRange.getBegin(), SrcClass, 0) || > + !Self.IsDerivedFrom(SrcClass, DestClass, Paths)) { > return TC_NotApplicable; > } > > > Modified: cfe/trunk/test/SemaCXX/static-cast.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/static-cast.cpp?rev=199374&r1=199373&r2=199374&view=diff > > ============================================================================== > --- cfe/trunk/test/SemaCXX/static-cast.cpp (original) > +++ cfe/trunk/test/SemaCXX/static-cast.cpp Thu Jan 16 06:02:55 2014 > @@ -9,6 +9,8 @@ struct F : public C1 {}; // S > struct G1 : public B {}; > struct G2 : public B {}; > struct H : public G1, public G2 {}; // Ambiguous path to B. > +struct I; // Incomplete. > +struct J; // Incomplete. > > enum Enum { En1, En2 }; > enum Onom { On1, On2 }; > @@ -131,6 +133,7 @@ void t_529_9() > // Bad code below > (void)static_cast<int A::*>((int H::*)0); // expected-error {{ambiguous > conversion from pointer to member of derived class 'H' to pointer to member > of base class 'A':}} > (void)static_cast<int A::*>((int F::*)0); // expected-error > {{conversion from pointer to member of class 'F' to pointer to member of > class 'A' via virtual base 'B' is not allowed}} > + (void)static_cast<int I::*>((int J::*)0); // expected-error > {{static_cast from 'int J::*' to 'int I::*' is not allowed}} > } > > // PR 5261 - static_cast should instantiate template if possible > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
