[cfe-commits] r46549 - /cfe/trunk/include/clang/AST/Expr.h

Chris Lattner sabre at nondot.org
Tue Jan 29 21:53:56 PST 2008


Author: lattner
Date: Tue Jan 29 23:53:56 2008
New Revision: 46549

URL: http://llvm.org/viewvc/llvm-project?rev=46549&view=rev
Log:
Be more explicit about what flavors of initlistexpr's we can see.  I don't
know if all of this is exactly right, but it seems like the right thing to
aim for.  Steve, please review.

Modified:
    cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=46549&r1=46548&r2=46549&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Jan 29 23:53:56 2008
@@ -1204,7 +1204,24 @@
   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;





More information about the cfe-commits mailing list