From: Chris Lattner Date: Wed, 30 Jan 2008 05:53:56 +0000 (+0000) Subject: Be more explicit about what flavors of initlistexpr's we can see. I don't X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=196ef51bc4d008ec1c69851fb3b0f8d036065931;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46549 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 13bf6f52b7..7134d1c0f2 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -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;