http://llvm.org/bugs/show_bug.cgi?id=15916

            Bug ID: 15916
           Summary: Is AST for switch statement correctly?
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Steps to Reproduce:

1) Write simple code:
int main() {
  int a = 0;
  switch (a) {
    case 0:
      if (!a) break;
      if (a) break;
    break;
 }
}

2) Run a command for print AST:
clang++ -cc1 -ast-dump main.cpp 

Actual Results:
typedef char *__builtin_va_list;
int main() (CompoundStmt 0x9eb7020 </tmp/main.cpp:1:12, line:10:1>
  (DeclStmt 0x9eb6e90 <line:2:5, col:14>
    0x9eb6e40 "int a =
      (IntegerLiteral 0x9eb6e78 <col:13> 'int' 0)")
  (SwitchStmt 0x9eb6ec8 <line:4:2, line:9:2>
    <<<NULL>>>
    (ImplicitCastExpr 0x9eb6eb8 <line:4:10> 'int' <LValueToRValue>
      (DeclRefExpr 0x9eb6ea0 <col:10> 'int' lvalue Var 0x9eb6e40 'a' 'int'))
    (CompoundStmt 0x9eb7000 <col:13, line:9:2>
      (CaseStmt 0x9eb6f00 <line:5:9, line:6:21>
        (IntegerLiteral 0x9eb6ee8 <line:5:14> 'int' 0)
        <<<NULL>>>
        (IfStmt 0x9eb6f78 <line:6:13, col:21>
          <<<NULL>>>
          (UnaryOperator 0x9eb6f58 <col:17, col:18> '_Bool' prefix '!'
            (ImplicitCastExpr 0x9eb6f48 <col:18> '_Bool' <IntegralToBoolean>
              (ImplicitCastExpr 0x9eb6f38 <col:18> 'int' <LValueToRValue>
                (DeclRefExpr 0x9eb6f20 <col:18> 'int' lvalue Var 0x9eb6e40 'a'
'int'))))
          (BreakStmt 0x9eb6f70 <col:21>)
          <<<NULL>>>))
      (IfStmt 0x9eb6fd8 <line:7:13, col:20>
        <<<NULL>>>
        (ImplicitCastExpr 0x9eb6fc0 <col:17> '_Bool' <IntegralToBoolean>
          (ImplicitCastExpr 0x9eb6fb0 <col:17> 'int' <LValueToRValue>
            (DeclRefExpr 0x9eb6f94 <col:17> 'int' lvalue Var 0x9eb6e40 'a'
'int')))
        (BreakStmt 0x9eb6fd0 <col:20>)
        <<<NULL>>>)
      (BreakStmt 0x9eb6ff8 <line:8:3>))))

Expected Results:
  Why second IfStmt isn't child of CaseStmt?


clang --version
Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)
Target: i386-pc-linux-gnu
Thread model: posix

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to