From: Eli Friedman Date: Mon, 4 May 2009 04:39:55 +0000 (+0000) Subject: PR4143: don't crash generating debug info for incomplete enum types. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3189e4be4f79f22e0e076e21615b9526de529b43;p=clang PR4143: don't crash generating debug info for incomplete enum types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70825 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index ac1616b933..c11e8ce0ad 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -520,8 +520,12 @@ llvm::DIType CGDebugInfo::CreateType(const EnumType *Ty, // Size and align of the type. - uint64_t Size = M->getContext().getTypeSize(Ty); - unsigned Align = M->getContext().getTypeAlign(Ty); + uint64_t Size = 0; + unsigned Align = 0; + if (!Ty->isIncompleteType()) { + Size = M->getContext().getTypeSize(Ty); + Align = M->getContext().getTypeAlign(Ty); + } return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_enumeration_type, Unit, EnumName, DefUnit, Line, diff --git a/test/CodeGen/debug-info.c b/test/CodeGen/debug-info.c index 0cb01a34cd..e0ec2c9027 100644 --- a/test/CodeGen/debug-info.c +++ b/test/CodeGen/debug-info.c @@ -28,3 +28,10 @@ struct foo { void *ptrs[]; }; struct foo bar; + +// PR4143 +struct foo2 { + enum bar *bar; +}; + +struct foo2 foo2;