]> granicus.if.org Git - clang/commitdiff
Be more explicit about what flavors of initlistexpr's we can see. I don't
authorChris Lattner <sabre@nondot.org>
Wed, 30 Jan 2008 05:53:56 +0000 (05:53 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 30 Jan 2008 05:53:56 +0000 (05:53 +0000)
know if all of this is exactly right, but it seems like the right thing to
aim for.  Steve, please review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46549 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h

index 13bf6f52b7f4b4df29668675833637e2def1f09f..7134d1c0f292667dc153939fca06614343a02835 100644 (file)
@@ -1204,7 +1204,24 @@ public:
   virtual child_iterator child_end();  
 };
   
-/// InitListExpr, used for struct and array initializers.
+/// InitListExpr - used for struct and array initializers, such as:
+///    struct foo x = { 1, { 2, 3 } };
+///
+/// Because C is somewhat loose with braces, the AST does not necessarily
+/// directly model the C source.  Instead, the semantic analyzer aims to make
+/// the InitListExprs match up with the type of the decl being initialized.  We
+/// have the following exceptions:
+///
+///  1. Elements at the end of the list may be dropped from the initializer.  
+///     These elements are defined to be initialized to zero.  For example:
+///         int x[20] = { 1 };
+///  2. Initializers may have excess initializers which are to be ignored by the
+///     compiler.  For example:
+///         int x[1] = { 1, 2 };
+///  3. Redundant InitListExprs may be present.  These always have a single
+///     element whose type is the same as the InitListExpr.
+///         int x = { 1 };  int y[2] = { {1}, {2} };
+///
 class InitListExpr : public Expr {
   Expr **InitExprs;
   unsigned NumInits;