[cfe-commits] P4R: Update initializer's type if checking it updates the decl's type

Christopher Lamb christopher.lamb at gmail.com
Thu Nov 29 00:47:45 PST 2007


This was preventing CodeGen for

int ary[] = {1, 2, 3, 4};

because the initializer's type was of the original decl's type with  
an element count of zero.


Index: Sema/SemaDecl.cpp
===================================================================
--- Sema/SemaDecl.cpp	(revision 44432)
+++ Sema/SemaDecl.cpp	(working copy)
@@ -727,8 +727,10 @@
    // completed by the initializer. For example:
    //   int ary[] = { 1, 3, 5 };
    // "ary" transitions from a VariableArrayType to a  
ConstantArrayType.
-  if (!VDecl->isInvalidDecl() && (DclT != SavT))
+  if (!VDecl->isInvalidDecl() && (DclT != SavT)) {
      VDecl->setType(DclT);
+    Init->setType(DclT);
+  }

    // Attach the initializer to the decl.
    VDecl->setInit(Init);

--
Christopher Lamb



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20071129/ea98c361/attachment.html>


More information about the cfe-commits mailing list