NoQ added a comment.

  $ cat test.c
  #include <stdio.h>
  int main() {
    int i = 5;
    {
      int i = i;
      printf("%d\n", i);
    }
    return 0;
  }
  $ clang test.c
  $ ./a.out
  32767
  $ clang test.c -Xclang -ast-dump
  ...
  `-FunctionDecl 0x7ff82d8eac78 <test.c:2:1, line:9:1> line:2:5 main 'int ()'
    `-CompoundStmt 0x7ff82d8eb070 <col:12, line:9:1>
      |-DeclStmt 0x7ff82d8eadb0 <line:3:3, col:12>
      | `-VarDecl 0x7ff82d8ead30 <col:3, col:11> col:7 i 'int' cinit
      |   `-IntegerLiteral 0x7ff82d8ead90 <col:11> 'int' 5
      |-CompoundStmt 0x7ff82d8eb010 <line:4:3, line:7:3>
      | |-DeclStmt 0x7ff82d8eae78 <line:5:5, col:14>
      | | `-VarDecl 0x7ff82d8eadd8 <col:5, col:13> col:9 used i 'int' cinit
      | |   `-ImplicitCastExpr 0x7ff82d8eae60 <col:13> 'int' <LValueToRValue>
      | |     `-DeclRefExpr 0x7ff82d8eae38 <col:13> 'int' lvalue Var 
0x7ff82d8eadd
  ...

It seems that in `int i = i;` the `i` in the new `i`, which is already declared 
by now, just not initialized yet, rather than the old `i`.


https://reviews.llvm.org/D23418



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to