diff options
-rw-r--r-- | lib/Sema/SemaExceptionSpec.cpp | 5 | ||||
-rw-r--r-- | test/SemaCXX/exception-spec.cpp | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 4171ecea8a..261bebf955 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -26,6 +26,8 @@ static const FunctionProtoType *GetUnderlyingFunction(QualType T) T = PtrTy->getPointeeType(); else if (const ReferenceType *RefTy = T->getAs<ReferenceType>()) T = RefTy->getPointeeType(); + else if (const MemberPointerType *MPTy = T->getAs<MemberPointerType>()) + T = MPTy->getPointeeType(); return T->getAs<FunctionProtoType>(); } @@ -171,6 +173,9 @@ bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID, SubE = Subset->exception_end(); SubI != SubE; ++SubI) { // Take one type from the subset. QualType CanonicalSubT = Context.getCanonicalType(*SubI); + // Unwrap pointers and references so that we can do checks within a class + // hierarchy. Don't unwrap member pointers; they don't have hierarchy + // conversions on the pointee. bool SubIsPointer = false; if (const ReferenceType *RefTy = CanonicalSubT->getAs<ReferenceType>()) CanonicalSubT = RefTy->getPointeeType(); diff --git a/test/SemaCXX/exception-spec.cpp b/test/SemaCXX/exception-spec.cpp index bd22bf3ddd..f55a4494ea 100644 --- a/test/SemaCXX/exception-spec.cpp +++ b/test/SemaCXX/exception-spec.cpp @@ -166,3 +166,17 @@ void fnptrs() void (*t11)(void (*)() throw(A)) = &s9; // expected-error {{argument types differ}} expected-error {{incompatible type}} expected-warning{{disambiguated}} void (*t12)(void (*)() throw(D)) = &s9; // expected-error {{argument types differ}} expected-error {{incompatible type}} expected-warning{{disambiguated}} } + +// Member function stuff + +struct Str1 { void f() throw(int); }; // expected-note {{previous declaration}} +void Str1::f() // expected-error {{does not match previous declaration}} +{ +} + +void mfnptr() +{ + void (Str1::*pfn1)() throw(int) = &Str1::f; // valid + void (Str1::*pfn2)() = &Str1::f; // valid + void (Str1::*pfn3)() throw() = &Str1::f; // expected-error {{not superset}} expected-error {{incompatible type}} +} |