[cfe-dev] Fix warning

Neil Booth neil at daikokuya.co.uk
Mon Jul 23 15:30:58 PDT 2007


about potentially uninitialized vars Size and Align.

Neil.


-------------- next part --------------
Index: AST/ASTContext.cpp
===================================================================
--- AST/ASTContext.cpp	(revision 40450)
+++ AST/ASTContext.cpp	(working copy)
@@ -227,14 +227,14 @@
     break;
   }
   case Type::Tagged:
-    if (RecordType *RT = dyn_cast<RecordType>(cast<TagType>(T))) {
-      const RecordLayout &Layout = getRecordLayout(RT->getDecl(), L);
-      Size = Layout.getSize();
-      Align = Layout.getAlignment();
-      break;
-    }
-    // FIXME: Handle enums.
-    assert(0 && "Unimplemented type sizes!");
+    RecordType *RT = dyn_cast<RecordType>(cast<TagType>(T));
+    if (!RT)
+      // FIXME: Handle enums.
+      assert(0 && "Unimplemented type sizes!");
+    const RecordLayout &Layout = getRecordLayout(RT->getDecl(), L);
+    Size = Layout.getSize();
+    Align = Layout.getAlignment();
+    break;
   }
   
   assert(Align && (Align & (Align-1)) == 0 && "Alignment must be power of 2");


More information about the cfe-dev mailing list