[cfe-dev] AST for C++11 brace initialization includes CompoundLiteralExpr?

Douglas Gregor dgregor at apple.com
Fri May 3 11:18:30 PDT 2013

On May 3, 2013, at 11:16 AM, Jordan Rose <jordan_rose at apple.com> wrote:

> How about this one? Is the inner init list really creating a Point which is then copied by the CompoundLiteralExpr?

> struct Point {
> 	int x, y;
> 	~Point();
> };
> void test() {
> 	((Point){1,2});
> }
> `-FunctionDecl 0x7f9558860720 <line:6:1, line:8:1> test 'void (void)'
>   `-CompoundStmt 0x7f9558860990 <line:6:13, line:8:1>
>     `-ExprWithCleanups 0x7f9558860978 <line:7:2, col:15> 'struct Point'
>       `-ParenExpr 0x7f9558860958 <col:2, col:15> 'struct Point'
>         `-CXXBindTemporaryExpr 0x7f9558860938 <col:3, col:14> 'struct Point' (CXXTemporary 0x7f9558860930)
>           `-CompoundLiteralExpr 0x7f9558860908 <col:3, col:14> 'struct Point'
>             `-CXXBindTemporaryExpr 0x7f95588608e8 <col:10, col:14> 'struct Point' (CXXTemporary 0x7f95588608e0)
>               `-InitListExpr 0x7f9558860860 <col:10, col:14> 'struct Point'
>                 |-IntegerLiteral 0x7f95588607d0 <col:11> 'int' 1
>                 `-IntegerLiteral 0x7f95588607f0 <col:13> 'int' 2
> (This is the same AST whether in C++03 or C++11.)

Okay, that's weird. There should just be one temporary there.

	- Doug

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130503/1be9831f/attachment.html>

More information about the cfe-dev mailing list