<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 14 August 2013 12:47, Abramo Bagnara <span dir="ltr"><<a href="mailto:abramo.bagnara@bugseng.com" target="_blank">abramo.bagnara@bugseng.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Il 14/08/2013 12:33, Pavel Labath ha scritto:<br>
<div class="im">><br>
><br>
>> Could you please elaborate on that? I'm not sure what you mean by<br></div><div><div class="h5">
> repeated initializers. Do you know of a situation where an AST node can<br>
> be present in the tree twice?<br>
><br>
</div></div>$ cat p.c<br>
void f() {<br>
  int a[10] = {[1 ... 8] = 2};<br>
}<br>
$ clang -cc1 -ast-dump p.c<br>
TranslationUnitDecl 0x54ae6e0 <<invalid sloc>><br>
|-TypedefDecl 0x54aebc0 <<invalid sloc>> __int128_t '__int128'<br>
|-TypedefDecl 0x54aec20 <<invalid sloc>> __uint128_t 'unsigned __int128'<br>
|-TypedefDecl 0x54aef70 <<invalid sloc>> __builtin_va_list<br>
'__va_list_tag [1]'<br>
`-FunctionDecl 0x54af010 <p.c:1:1, line:3:1> f 'void ()'<br>
  `-CompoundStmt 0x54af330 <line:1:10, line:3:1><br>
    `-DeclStmt 0x54af318 <line:2:3, col:30><br>
      `-VarDecl 0x54af130 <col:3, col:29> a 'int [10]'<br>
        `-InitListExpr 0x54af280 <col:15, col:29> 'int [10]'<br>
          |-ImplicitValueInitExpr 0x54af308 <<invalid sloc>> 'int'<br>
          |-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
          |-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
          |-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
          |-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
          |-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
          |-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
          |-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
          `-IntegerLiteral 0x54af1c8 <col:28> 'int' 2<br>
<br></blockquote><div><div><br class="">Wow.. I didn't even know such syntax exists. This is a nice example, thanks.</div><div><br></div><div>Right now, the static analyzer seems to get this code right (which is quite surprising, since even the compiler does not support this right now), but as soon as I replace 2 by something more complicated (a function call), it stops for some reason, which I didn't investigate yet. But in any case, the analyzers approach to this is wrong, as it tries to evaluate the expression multiple times, which, I guess, it shouldn't (gcc doesn't).</div>
</div><div><br></div><div>Since the compiler doesn't support this yet, I guess this is not such an important issue yet, but it's definitely a thing to keep an eye on.</div><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Soon or later I personally hope that such node replication will<br>
disappear, but currently we have it and I don't know if there is the<br>
intention to get rid of it.<br><br></blockquote><div><br></div><div>I think I would also prefer a different AST representation of the above code, because the current one gives the impression that the RHS expression is to be evaluated multiple times.</div>
<div><br></div><div>cheers,</div><div>pavel</div></div></div></div>