]> granicus.if.org Git - clang/commitdiff
PR4143: don't crash generating debug info for incomplete enum types.
authorEli Friedman <eli.friedman@gmail.com>
Mon, 4 May 2009 04:39:55 +0000 (04:39 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 4 May 2009 04:39:55 +0000 (04:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70825 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGen/debug-info.c

index ac1616b933d4fec32cb277d366f27d67439580b9..c11e8ce0ad70803e40035e2f353326a8c105b688 100644 (file)
@@ -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,
index 0cb01a34cdc379d0bc0bcd45105295a91b777948..e0ec2c9027cf9464a8717d8a987fc5c313932fb7 100644 (file)
@@ -28,3 +28,10 @@ struct foo {
        void *ptrs[];
 };
 struct foo bar;
+
+// PR4143
+struct foo2 {
+        enum bar *bar;
+};
+
+struct foo2 foo2;