From 2ad7e170969e3f1bc6c876b2f7f11a76e7eab1e0 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 4 May 2009 04:39:55 +0000 Subject: [PATCH] PR4143: don't crash generating debug info for incomplete enum types. llvm-svn: 70825 --- clang/lib/CodeGen/CGDebugInfo.cpp | 8 ++++++-- clang/test/CodeGen/debug-info.c | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index ac1616b933d4..c11e8ce0ad70 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/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/clang/test/CodeGen/debug-info.c b/clang/test/CodeGen/debug-info.c index 0cb01a34cdc3..e0ec2c9027cf 100644 --- a/clang/test/CodeGen/debug-info.c +++ b/clang/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;