diff options
| -rw-r--r-- | clang/lib/CodeGen/CGVTables.cpp | 2 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/microsoft-abi-thunks.cpp | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index d530016f13b..425c12301fd 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -481,7 +481,7 @@ void CodeGenVTables::maybeEmitThunkForVTable(GlobalDecl GD, // We can't emit thunks for member functions with incomplete types. const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl()); if (!CGM.getTypes().isFuncTypeConvertible( - cast<FunctionType>(MD->getType().getTypePtr()))) + MD->getType()->castAs<FunctionType>())) return; emitThunk(GD, Thunk, /*ForVTable=*/true); diff --git a/clang/test/CodeGenCXX/microsoft-abi-thunks.cpp b/clang/test/CodeGenCXX/microsoft-abi-thunks.cpp index 091ef3274b9..3b4281f76d6 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-thunks.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-thunks.cpp @@ -116,3 +116,18 @@ struct H : E { H h; // FIXME: Write vtordisp adjusting thunk tests + +namespace CrashOnThunksForAttributedType { +// We used to crash on this because the type of foo is an AttributedType, not +// FunctionType, and we had to look through the sugar. +struct A { + virtual void __stdcall foo(); +}; +struct B { + virtual void __stdcall foo(); +}; +struct C : A, B { + virtual void __stdcall foo(); +}; +C c; +} |

