[llvm-branch-commits] [llvm-branch] r133691 - /llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp

Chris Lattner sabre at nondot.org
Wed Jun 22 23:09:34 PDT 2011


Author: lattner
Date: Thu Jun 23 01:09:34 2011
New Revision: 133691

URL: http://llvm.org/viewvc/llvm-project?rev=133691&view=rev
Log:
diagnose struct element initializer mismatches more nicely.

Modified:
    llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp

Modified: llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp?rev=133691&r1=133690&r2=133691&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/AsmParser/LLParser.cpp Thu Jun 23 01:09:34 2011
@@ -2517,6 +2517,12 @@
       if (ST->isPacked() != (ID.Kind == ValID::t_PackedConstantStruct))
         return Error(ID.Loc, "packed'ness of initializer and type don't match");
         
+      // Verify that the elements are compatible with the structtype.
+      for (unsigned i = 0, e = ID.UIntVal; i != e; ++i)
+        if (ID.ConstantStructElts[i]->getType() != ST->getElementType(i))
+          return Error(ID.Loc, "element " + Twine(i) +
+                    " of struct initializer doesn't match struct element type");
+      
       V = ConstantStruct::get(ST, ArrayRef<Constant*>(ID.ConstantStructElts,
                                                       ID.UIntVal));
     } else





More information about the llvm-branch-commits mailing list