From: Reid Kleckner Date: Wed, 20 Jun 2018 21:12:20 +0000 (+0000) Subject: [MS] Make sure __GetExceptionInfo works on types with no linkage X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=443ea9f82a450eca95affcddefed86a5aec03618;p=clang [MS] Make sure __GetExceptionInfo works on types with no linkage Fixes PR36327 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335175 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index aa4f6461b6..7a8cd1ca4e 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -645,6 +645,8 @@ void Sema::getUndefinedButUsed( !isExternalWithNoLinkageType(FD) && !FD->getMostRecentDecl()->isInlined()) continue; + if (FD->getBuiltinID()) + continue; } else { auto *VD = cast(ND); if (VD->hasDefinition() != VarDecl::DeclarationOnly) diff --git a/test/CodeGenCXX/microsoft-abi-throw.cpp b/test/CodeGenCXX/microsoft-abi-throw.cpp index 8800e97a03..cbbce2daaa 100644 --- a/test/CodeGenCXX/microsoft-abi-throw.cpp +++ b/test/CodeGenCXX/microsoft-abi-throw.cpp @@ -22,6 +22,7 @@ // CHECK-DAG: @_TI1P6AXXZ = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @_CTA1P6AXXZ to i8*) }, section ".xdata", comdat // CHECK-DAG: @_TIU2PAPFAH = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 4, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.2* @_CTA2PAPFAH to i8*) }, section ".xdata", comdat // CHECK-DAG: @_CTA2PAPFAH = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.2 { i32 2, [2 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0PAPFAH@84", %eh.CatchableType* @"_CT??_R0PAX@84"] }, section ".xdata", comdat +// CHECK-DAG: @"_TI1?AUFoo@?A@@" = internal unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @"_CTA1?AUFoo@?A@@" to i8*) }, section ".xdata" struct N { ~N(); }; @@ -128,3 +129,12 @@ void *GetExceptionInfo_test1() { // CHECK: ret i8* bitcast (%eh.ThrowInfo* @_TI1P6AXXZ to i8*) return __GetExceptionInfo(&h); } + +// PR36327: Try an exception type with no linkage. +namespace { struct Foo { } foo_exc; } + +void *GetExceptionInfo_test2() { +// CHECK-LABEL: @"?GetExceptionInfo_test2@@YAPAXXZ" +// CHECK: ret i8* bitcast (%eh.ThrowInfo* @"_TI1?AUFoo@?A@@" to i8*) + return __GetExceptionInfo(foo_exc); +}